-
Notifications
You must be signed in to change notification settings - Fork 3
Autoloader
Autoloading is a mechanism that eliminates the need to manually require dependencies within your PHP code. Using autoloading, you do not need to worry about where a class exists in your project. With well-defined autoloaders, you do not need to worry about where a class file is relative to the current class file; you simply use the class, and the autoloader will perform the file lookup. By extending Zend Framework Autoloader, Xoops Engine provides a customized autoloader.
Once an autoloader has been defined, it "is automatically called in case you are trying to use a class or an interface which hasn't been defined yet."
The autoloaders in Xoops Engine are:
- Kernel\Loader\ClassMapAutoloader::autoload()
- Kernel\Loader\StandardAutoloader::autoload()
- Kernel\Loader\Autoloader::dispatch()
- smartyAutoload()
They will be called in turns.
ClassMapAutoloader is the first autoloader class be called. It can loads these classes:
- Kernel\EngineInterface
- Kernel\HostInterface
- Kernel\Persist
- Kernel\Service
- Debug
StandardAutoloader can load classes with one of these prefixs or namespaces:
- Kernel
- Engine
- Xoops
- App
- Module
- Applet
If the prefix is not in the above, the StandardAutoloader will call it use fallback auloader. For example, the class name Zend_Acl_Role
will be transformed as filename XoopsEngin/lib/Zend/Acl/Role.php
.
Kernel\Loader\Autoloader is actually not a autoloader, it just setup and configurate ClassMapAutoloader and StandardAutoloader in Xoops Engine. The fallbackAutoloaderFlag of StandardAutoloader is be opened in Kernel\Loader\Autoloader.
smartyAutoload is a function. It is used for the smarty library in Xoops Engine.