(Yaf >=1.0.0)
Yaf_Loader::registerLocalNamespace — Register local namespace
$namespace, string $path = null): Yaf_Loader|falseRegister a local namespace. Classes whose prefix belongs to a local namespace are looked up under the given path (or the local library directory when no path is given) instead of the global one.
This lets you place your own classes into the local library directory, while shared classes live in the global library directory (see the yaf.library ini setting).
namespaceA namespace prefix string, or an array of prefix/path pairs (when the value is a path string) or prefix strings.
A prefix only matches at an underscore or backslash boundary: registering Models makes Models_User and Models itself local, but not ModelsUser. A leading backslash is ignored, and a class name written with backslashes is looked up as if they were underscores.
pathThe directory to look up the namespace in. If not given, the local library directory is used.
Returns the loader instance itself on success, or false if an invalid parameter is provided.
Example #1 Yaf_Loader::registerLocalNamespace() example
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract
{
public function _initLoader()
{
$loader = Yaf_Loader::getInstance();
/* Models_User is now looked up in
* APPLICATION_PATH/library/Models/User.php */
$loader->registerLocalNamespace("Models");
/* register several prefixes at once, each with its
* own lookup directory */
$loader->registerLocalNamespace(array(
"Services" => APPLICATION_PATH . "/services",
"Vendor" => APPLICATION_PATH . "/vendor",
));
}
}
?>