I’m using spl_autoload_register to load certain classes when they are needed, but how can I catch the error when the class is not found by my autoload method?
Right now the only solution I see is to display a cute error message in my autoload callback and stop the application so that error never gets to show.
But I don’t want to stop the application. I want to continue and skip the instantiation of the missing class I needed (in my specific case, they are not strictly required for the app to continue to run)
Use
class_exists()before loading and handle the result appropriately. If it exists, instantiate as per usual. If it doesn’t, skip the instantiation.