autoload VS spl_register_autoload
Posted: Sun Jul 26, 2009 2:25 pm
It seems each SPL autoload is executed obviously, unfortunately each one uses a different base directory and so when the first one is invoked it doesn't find the file and triggers an error, whereas the second is the appropriate autoload and does find the file but its too late as an error has already been raised.
I will likely use a file_exists and just exit silently if not found but I dislike this approach because I would actually like to know whether a class failed to include...
Ideally I only want the error to trigger after the last autoload has failed to find the file but being an autoload function the last thing I want in there is a GLOBAL or registry to keep track of an error stack.
Any ideas? Should I just log the error or take comfort in knowing that an object that doesn't have it's class included will trigger an error when instantiated?
I will likely use a file_exists and just exit silently if not found but I dislike this approach because I would actually like to know whether a class failed to include...
Ideally I only want the error to trigger after the last autoload has failed to find the file but being an autoload function the last thing I want in there is a GLOBAL or registry to keep track of an error stack.
Any ideas? Should I just log the error or take comfort in knowing that an object that doesn't have it's class included will trigger an error when instantiated?