(Yaf >=3.2.0)
Yaf_Loader::registerNamespace — registerLocalNamespace 的别名
$name_prefix, string $path = null): Yaf_Loader|false|nullname_prefix命名空间前缀字符串,或者前缀/路径对(当值为路径字符串时)或前缀字符串组成的数组。
path查找该命名空间的目录。如果未提供,则使用本地库目录。
成功时返回加载器实例自身,如果提供了无效参数则返回 false。
示例 #1 Yaf_Loader::registerNamespace() 示例
<?php
class Bootstrap extends Yaf_Bootstrap_Abstract
{
public function _initLoader()
{
/* registerNamespace() 是 registerLocalNamespace() 的别名 */
Yaf_Loader::getInstance()->registerNamespace(
"Vendor",
APPLICATION_PATH . "/library/Vendor"
);
}
}
/* new Vendor_Payment_Gateway() 现在会在
* APPLICATION_PATH/library/Vendor/Payment/Gateway.php 中查找 */
?>