本文整理汇总了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();
示例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);
}
示例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();
示例4: Autoloader
<?php
require "app/autoloader.php";
$loader = new Autoloader();
$loader->addNamespace('app', __DIR__ . '/app');
$loader->register();
示例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');
示例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');
示例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();
示例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');
示例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']);