Yaf_Loader::autoload
(Yaf >=1.0.0)
Autoload a class
Description
Load a class by its name. The class name is converted to a file path: underscores and namespace separators become directory separators.
MVC classes (classes whose names contain _Controller, _Action or _Plugin) are looked up under the application directory, while other classes are looked up in the library directories: the local library for locally registered class prefixes, otherwise the global library.
Parameters
class_nameThe class name to load.
Return Values
Returns true on success, or false on failure.
Examples
Yaf_Loader::autoload example
<?php
/*
* autoload() is normally invoked implicitly by the engine
* whenever an undefined class is referenced, but it can also
* be called explicitly to force loading of a class file.
*/
$loader = Yaf_Loader::getInstance("/var/www/shop/application/library");
/* looks up /var/www/shop/application/library/Catalog/PriceService.php */
$loader->autoload("Catalog_PriceService");
/* MVC classes are looked up under the application directory */
$loader->autoload("ProductController");
?>See Also
Yaf_Loader::importYaf_Loader::registerLocalNamespace