當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Autoloader::addNamespace方法代碼示例

本文整理匯總了PHP中Autoloader::addNamespace方法的典型用法代碼示例。如果您正苦於以下問題:PHP Autoloader::addNamespace方法的具體用法?PHP Autoloader::addNamespace怎麽用?PHP Autoloader::addNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Autoloader的用法示例。


在下文中一共展示了Autoloader::addNamespace方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getRegisteredAutoloaders

    public function getRegisteredAutoloaders()
    {
        return spl_autoload_functions();
    }
    /**
     * Dynamic new, a simple factory.
     * It loads and constructs a class, with provided arguments.
     *
     * @param   bool     $classname    Classname.
     * @param   array    $arguments    Arguments for the constructor.
     * @return  object
     */
    public static function dnew($classname, array $arguments = [])
    {
        $classname = ltrim($classname, '\\');
        if (false === Consistency::entityExists($classname, false)) {
            spl_autoload_call($classname);
        }
        $class = new \ReflectionClass($classname);
        if (empty($arguments) || false === $class->hasMethod('__construct')) {
            return $class->newInstance();
        }
        return $class->newInstanceArgs($arguments);
    }
}
/**
 * Autoloader.
 */
$autoloader = new Autoloader();
$autoloader->addNamespace('Hoa', dirname(__DIR__));
$autoloader->register();
開發者ID:Metalaka,項目名稱:Consistency,代碼行數:31,代碼來源:Autoloader.php

示例2: addNamespace

 /**
  * Add a new namespace together with an array of its corresponding base directories.
  *
  * @param string $namespace_name
  * @param string $corresponding_base_directory
  * @param boolean|null $prepend
  * @see Autoloader::addNamespace(string, string, boolean)
  * @return void
  */
 public function addNamespace(string $namespace_name, string $corresponding_base_directory, $prepend = false)
 {
     $this->autoloader->addNamespace($namespace_name, $corresponding_base_directory, $prepend);
 }
開發者ID:Karabow-Inc,項目名稱:Pluginizer-framework,代碼行數:13,代碼來源:autoloader_register.php

示例3: dirname

<?php

/**
 * Team Management Tool
 * 
 * This file is the initializer for all requests made to the TMT
 * 
 * @package team-management-tool
 * @license proprietary
 */
namespace TMT;

// Composer Autoloader
require dirname(__FILE__) . "/../vendor/autoload.php";
// Initialize TMT Autoloader
require 'autoload.php';
$al = new Autoloader();
$al->addNamespace("TMT\\app\\", "applications");
$al->addNamespace("TMT\\api\\", "apis");
$al->addNamespace("TMT\\model\\", "models");
$al->addNamespace("TMT\\accessor\\", "accessors");
$al->addNamespace("TMT\\controller\\", "controllers");
$al->addNamespace("TMT\\exception\\", "exceptions");
$al->addNamespace("TMT\\", "libs");
$al->register();
$app = new \TMT\TMT();
$app->handle();
開發者ID:byu-oit-ssengineering,項目名稱:team-managment-tool,代碼行數:27,代碼來源:init.php

示例4: Autoloader

<?php

require "app/autoloader.php";
$loader = new Autoloader();
$loader->addNamespace('app', __DIR__ . '/app');
$loader->register();
開發者ID:qimus,項目名稱:graph,代碼行數:6,代碼來源:bootstrap.php

示例5: natsort

    natsort($classes);
    foreach ($classes as $class) {
        if (stristr($class, 'ComposerAutoloaderInit')) {
            $result = true;
            break;
        }
    }
    return $result;
}
// The base path to /src/ if we don't have Composer we need to know root path
define('CLICKALICIOUS_RNG_BASE_PATH', realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
// Root node
$root = realpath(CLICKALICIOUS_RNG_BASE_PATH . '../');
// Check for composer existence
if (true === ($composerExist = $composerRunning = file_exists($root . '/vendor/autoload.php'))) {
    include_once $root . '/vendor/autoload.php';
} else {
    $composerExist = $composerRunning = composerRunning();
}
// No need to double detect and so on ...
define('CLICKALICIOUS_RNG_COMPOSER_EXISTS', $composerExist);
define('CLICKALICIOUS_RNG_COMPOSER_RUNNING', $composerRunning);
// Force reporting of all errors ...
error_reporting(-1);
// Init autoloading
$loader = new Autoloader();
// register the autoloader
$loader->register();
// register the base directories for the namespace prefix
$loader->addNamespace('Clickalicious\\Rng', CLICKALICIOUS_RNG_BASE_PATH . 'Clickalicious\\Rng');
開發者ID:clickalicious,項目名稱:rng,代碼行數:30,代碼來源:Bootstrap.php

示例6: realpath

        if (stristr($class, 'ComposerAutoloaderInit')) {
            $result = true;
            break;
        }
    }
    return $result;
}
// The base path to /lib/ if we don't have Composer we need to know root path
define('CLICKALICIOUS_MEMCACHED_BASE_PATH', realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
// Root node
$root = realpath(CLICKALICIOUS_MEMCACHED_BASE_PATH . '../');
// Check for composer existence
if (true === ($composerExist = $composerRunning = file_exists($root . '/vendor/autoload.php'))) {
    include_once $root . '/vendor/autoload.php';
} else {
    $composerExist = $composerRunning = composer_running();
}
// No need to double detect and so on ...
define('CLICKALICIOUS_MEMCACHED_COMPOSER_EXISTS', $composerExist);
define('CLICKALICIOUS_MEMCACHED_COMPOSER_RUNNING', $composerRunning);
// Force reporting of all errors ...
error_reporting(-1);
// Retrieve SAPI PHP is running
$sapi = strtolower(php_sapi_name());
// Init autoloading
$loader = new Autoloader();
// register the autoloader
$loader->register();
// register the base directories for the namespace prefix
$loader->addNamespace('Clickalicious\\Memcached', CLICKALICIOUS_MEMCACHED_BASE_PATH . 'Clickalicious\\Memcached');
開發者ID:xiaobailc,項目名稱:Memcached.php,代碼行數:30,代碼來源:Bootstrap.php

示例7: die

// -------------------------------------------------------------------
// load composer
// -------------------------------------------------------------------
if (file_exists('vendor' . DS . 'autoload.php')) {
    require_once 'vendor' . DS . 'autoload.php';
} else {
    die("Fatal Error: Composer autoload file not found!");
}
// -------------------------------------------------------------------
// Set the root directory and add trailing slash
// -------------------------------------------------------------------
define('ROOT', \Stringy\Stringy::create(dirname(__DIR__), 'UTF-8')->ensureRight(DS));
// -------------------------------------------------------------------
// Set the storage directory (used for auto-updating docs)
// -------------------------------------------------------------------
define('STORAGE_ROOT', ROOT . 'Storage' . DS);
// -------------------------------------------------------------------
// Set the system autoloader
// -------------------------------------------------------------------
if (file_exists(ROOT . 'System' . DS . 'Autoloader.php')) {
    require_once ROOT . 'System' . DS . 'Autoloader.php';
} else {
    die("Fatal Error: System autoload file not found!");
}
$loader = new Autoloader();
$loader->register();
$loader->addNamespace('DocMark', dirname(__DIR__));
// -------------------------------------------------------------------
// Start DocMark
// -------------------------------------------------------------------
$docmark = new \DocMark\System\Docmark();
開發者ID:snscripts,項目名稱:docmark,代碼行數:31,代碼來源:Init.php

示例8: requireFile

            if ($this->requireFile($file)) {
                // yes, we're done
                return $file;
            }
        }
        // never found it
        return false;
    }
    /**
     * If a file exists, require it from the file system.
     *
     * @param string $file The file to require.
     *
     * @return bool True if the file exists, false if not.
     */
    protected function requireFile($file)
    {
        if (file_exists($file)) {
            require $file;
            return true;
        }
        return false;
    }
}
// instantiate the loader
$loader = new Autoloader();
// register the autoloader
$loader->register();
// register the base directories for the namespace prefix
$loader->addNamespace('TokenToMe\\TwitterCards', JM_TC_DIR . 'classes');
開發者ID:eugene-gromky-co,項目名稱:mindfulnesssummit,代碼行數:30,代碼來源:autoload.php

示例9: requireFile

            // in the relative class name, append with .php
            $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
            // if the mapped file exists, require it
            if ($this->requireFile($file)) {
                // yes, we're done
                return $file;
            }
        }
        // never found it
        return false;
    }
    /**
     * If a file exists, require it from the file system.
     *
     * @param string $file The file to require.
     * @return bool True if the file exists, false if not.
     */
    protected function requireFile($file)
    {
        if (file_exists($file)) {
            require $file;
            return true;
        }
        return false;
    }
}
$loader = new Autoloader();
$loader->register();
$loader->addNamespace('Libs', $GLOBALS['directories']['libs']);
$loader->addNamespace('Services', $GLOBALS['directories']['services']);
$loader->addNamespace('Controllers', $GLOBALS['directories']['controllers']);
開發者ID:Fedeorlandau,項目名稱:ArnoldPHP,代碼行數:31,代碼來源:autoload.php


注:本文中的Autoloader::addNamespace方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。