« Yaf_Loader::registerLocalNamespace
Yaf_Loader::setLibraryPath »

Yaf_Loader::registerNamespace

(Yaf >=3.2.0)

Yaf_Loader::registerNamespace — Alias of registerLocalNamespace

説明

public function Yaf_Loader::registerNamespace(string|array $namespace, string $path = null): Yaf_Loader|false

Alias of Yaf_Loader::registerLocalNamespace().

パラメータ

namespace

A namespace prefix string, or an array of prefix/path pairs (when the value is a path string) or prefix strings.

path

The 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.

例

例1 Yaf_Loader::registerNamespace() example

<?php
class Bootstrap extends Yaf_Bootstrap_Abstract
{
    public function _initLoader()
    {
        /* registerNamespace() is an alias of registerLocalNamespace() */
        Yaf_Loader::getInstance()->registerNamespace(
            "Vendor",
            APPLICATION_PATH . "/library/Vendor"
        );
    }
}

/* new Vendor_Payment_Gateway() is now looked up in
 * APPLICATION_PATH/library/Vendor/Payment/Gateway.php */
?>

参考

関連キーワード:
Loader   registerLocalNamespace   registerNamespace   Alias   namespace   path   Vendor   prefix   library   directory   Bootstrap   Payment   Gateway   setLibraryPath   pairs   strings   look   given   local   used   loader   instance   itself   success   invalid
関連する関数・ページ:
yaf-loader.registerlocalnamespace   yaf-loader.construct   yaf-loader.setlibrarypath   yaf-loader.getnamespaces   yaf-loader.getlibrarypath   yaf-loader.import