Yaf_Loader::registerLocalNamespace
(Yaf >=1.0.0)
Yaf_Loader::registerLocalNamespace — register local class prefix
Описание
Register local class prefix name, Yaf_Loader search classes in two library directories, the one is configured via application.library.directory(in application.ini) which is called local libraray directory; the other is configured via yaf.library (in php.ini) which is callled global library directory, since it can be shared by many applications in the same server.
When an autloading is trigger, Yaf_Loader will determine which library directory should be searched in by exame the prefix name of the missed classname. If the prefix name is registered as a localnamespack then look for it in local library directory, otherwise look for it in global library directory.
Замечание:
If yaf.library is not configured, then the global library directory is assumed to be the local library directory. in that case, all autoloading will look for local library directory. But if you want your Yaf application be strong, then always register your own classes as local classes.
Список параметров
-
prefix
-
a string or a array of class name prefix. all class prefix with these prefix will be loaded in local library path.
Возвращаемые значения
bool
Примеры
Пример #1 Yaf_Loader::registerLocalNamespace()example
<?php
$loader = Yaf_Loader::getInstance('/local/library/', '/global/library');
$loader->registerLocalNamespace("Baidu");
$loader->registerLocalNamespace(array("Sina", "Weibo"));
$loader->autoload("Baidu_Name"); // search in '/local/library/'
$loader->autoload("Sina"); // search '/local/library/'
$loader->autoload("Global_Name");// search in '/global/library/'
$loader->autoload("Foo_Bar"); // search in '/global/library/'
?>
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Другие базовые расширения
- Yet Another Framework
- Функция Yaf_Loader::autoload() - The autoload purpose
- Функция Yaf_Loader::clearLocalNamespace() - The clearLocalNamespace purpose
- Функция Yaf_Loader::__clone() - The __clone purpose
- Функция Yaf_Loader::__construct() - The __construct purpose
- Функция Yaf_Loader::getInstance() - The getInstance purpose
- Функция Yaf_Loader::getLibraryPath() - get the library path
- Функция Yaf_Loader::getLocalNamespace() - The getLocalNamespace purpose
- Функция Yaf_Loader::import() - The import purpose
- Функция Yaf_Loader::isLocalName() - The isLocalName purpose
- Функция Yaf_Loader::registerLocalNamespace() - register local class prefix
- Функция Yaf_Loader::setLibraryPath() - Change the library path
- Функция Yaf_Loader::__sleep() - The __sleep purpose
- Функция Yaf_Loader::__wakeup() - The __wakeup purpose
Коментарии
404 Not Found