Caution: The documentation you are viewing is
for an older version of Zend Framework.
You can find the documentation of the current version at:
https://docs.zendframework.com/
The SplAutoloader Interface - Zend_Loader
While any valid PHP callback may be registered with spl_autoload_register(), Zend Framework autoloaders often provide more flexibility by being stateful and allowing configuration. To provide a common interface, Zend Framework provides the SplAutoloader interface.
Objects implementing this interface provide a standard mechanism for configuration, a method that may be invoked to attempt to load a class, and a method for registering with the SPL autoloading mechanism.
To create your own autoloading mechanism, simply create a class implementing the SplAutoloader interface (you may review the methods defined in the Methods section). As a simple example, consider the following autoloader, which will look for a class file named after the class within a list of registered directories.
This component defines no configuration options, as it is an interface.
Initialize and configure an autoloader
Autoloader constructors should optionally receive configuration options. Typically, if received, these will be passed to the setOptions() method to process.
Configure the autoloader state
Used to configure the autoloader. Typically, it should expect either an array or a Traversable object, though validation of the options is left to implementation. Additionally, it is recommended that the method return the autoloader instance in order to implement a fluent interface.
Attempt to resolve a class name to the file defining it
This method should be used to resolve a class name to the file defining it. When a positive match is found, return the class name; otherwise, return a boolean false.
Register the autoloader with the SPL autoloader
Should be used to register the autoloader instance with spl_autoload_register(). Invariably, the method should look like the following:
Please see the Quick Start for a complete example.