本文整理汇总了PHP中Autoloader类的典型用法代码示例。如果您正苦于以下问题:PHP Autoloader类的具体用法?PHP Autoloader怎么用?PHP Autoloader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Autoloader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register()
{
// Params
set_time_limit(0);
clearstatcache();
// Error log
$this->initErrorHandling();
// External classes
require_once $this->getCorePath() . '/classes/class.util.php';
Util::logSeparator();
// Autoloader
require_once $this->getCorePath() . '/classes/class.autoloader.php';
$neardAutoloader = new Autoloader();
$neardAutoloader->register();
// Load
self::loadCore();
self::loadConfig();
self::loadLang();
self::loadBins();
self::loadTools();
self::loadApps();
self::loadWinbinder();
self::loadRegistry();
self::loadHomepage();
// Init
if ($this->isBootstrap) {
$this->procs = Win32Ps::getListProcs();
}
}
示例2: testAutoloaderUsesTokenizer
/**
* Asserts that the tokenizer is used as default
*
* @return void
*/
public function testAutoloaderUsesTokenizer()
{
$this->assertTrue(AutoloaderFileParser_Tokenizer::isSupported());
$autoloader = new Autoloader();
$autoloader->register();
$autoloader->remove();
$this->assertTrue($autoloader->getParser() instanceof AutoloaderFileParser_Tokenizer);
}
示例3: testAutoloaderIncludesMatchingSourceFile
/**
* @return void
* @covers \pdepend\reflection\Autoloader
* @group reflection
* @group unittest
*/
public function testAutoloaderIncludesMatchingSourceFile()
{
$classFixture = '\\pdepend\\reflection\\autoloader\\Test';
if (class_exists($classFixture, false)) {
$this->fail('Class ' . $classFixture . ' should not exist');
}
$autoloader = new Autoloader(__DIR__ . '/_source/');
$autoloader->autoload($classFixture);
$this->assertTrue(class_exists($classFixture, false), 'Class should exist ' . $classFixture);
}
示例4: __construct
/**
* __construct
*
* Constructs the object.
*
* @access public
* @param \Pimple $pimple
* @return void
*/
public function __construct(\Pimple $pimple)
{
$this->pimple = $pimple;
$this->config = $pimple['config'];
$this->setReporting();
$appDir = $this->config['general.appDir'] . 'src';
$appLoader = new Autoloader($this->config['general.namespace'], $appDir);
$appLoader->register();
$this->router = new Router($this->pimple);
$this->session = $this->pimple['session'];
$this->session->start();
$this->session->set('language', $this->session->get('language', $this->config['general.default_language']));
}
示例5: registerAutoloaders
/**
* This method will load and register a new autoloader for the system
* multiple autoloader instances may be used.
*/
public static function registerAutoloaders()
{
require_once 'Autoloader.php';
$autoloader = new Autoloader(__NAMESPACE__, BASE);
$autoloader->register();
/**
* Override Basic error handling with Whoops
*/
$whoopsload = new Autoloader('Whoops', BASE . 'vendor' . DS . 'filp' . DS . 'whoops' . DS . 'src' . DS . '');
$whoopsload->register();
$wh = new \Whoops\Run();
$wh->pushHandler(new \Whoops\Handler\PrettyPageHandler());
$wh->register();
}
示例6: LoadComponents
public static function LoadComponents()
{
$Components = array('Classes');
foreach ($Components as $Component) {
Autoloader::LoadOrder($Component);
}
}
示例7: addClassDir
/**
* Add a path to the class directories
*
* @param string $sDir The path to the directory
* @param string|null $sNamespace The associated namespace
* @param array $aExcluded The functions that are not to be exported
*
* @return boolean
*/
public function addClassDir($sDir, $sNamespace = null, array $aExcluded = array())
{
if (!is_dir($sDir = trim($sDir))) {
return false;
}
if (!($sNamespace = trim($sNamespace))) {
$sNamespace = null;
}
if ($sNamespace) {
$sNamespace = trim($sNamespace, '\\');
// If there is an autoloader, register the dir with PSR4 autoloading
if ($this->xAutoloader) {
$this->xAutoloader->setPsr4($sNamespace . '\\', $sDir);
}
} else {
if ($this->xAutoloader) {
// If there is an autoloader, register the dir with classmap autoloading
$itDir = new RecursiveDirectoryIterator($sDir);
$itFile = new RecursiveIteratorIterator($itDir);
// Iterate on dir content
foreach ($itFile as $xFile) {
// skip everything except PHP files
if (!$xFile->isFile() || $xFile->getExtension() != 'php') {
continue;
}
$this->xAutoloader->addClassMap(array($xFile->getBasename('.php') => $xFile->getPathname()));
}
}
}
$this->aClassDirs[] = array('path' => $sDir, 'namespace' => $sNamespace, 'excluded' => $aExcluded);
return true;
}
示例8: save
/**
* Formats the output and saved it to disc.
*
* @param string $identifier filename
* @param $contents $contents language array to save
* @return bool \File::update result
*/
public function save($identifier, $contents)
{
// store the current filename
$file = $this->file;
// save it
$return = parent::save($identifier, $contents);
// existing file? saved? and do we need to flush the opcode cache?
if ($file == $this->file and $return and static::$flush_needed) {
if ($this->file[0] !== '/' and (!isset($this->file[1]) or $this->file[1] !== ':')) {
// locate the file
if ($pos = strripos($identifier, '::')) {
// get the namespace path
if ($file = \Autoloader::namespace_path('\\' . ucfirst(substr($identifier, 0, $pos)))) {
// strip the namespace from the filename
$identifier = substr($identifier, $pos + 2);
// strip the classes directory as we need the module root
$file = substr($file, 0, -8) . 'lang' . DS . $identifier;
} else {
// invalid namespace requested
return false;
}
} else {
$file = \Finder::search('lang', $identifier);
}
}
// make sure we have a fallback
$file or $file = APPPATH . 'lang' . DS . $identifier;
// flush the opcode caches that are active
static::$uses_opcache and opcache_invalidate($file, true);
static::$uses_apc and apc_compile_file($file);
}
return $return;
}
示例9: testCacheFileCanBeManuallySaved
public function testCacheFileCanBeManuallySaved()
{
Autoloader::saveCachedPaths();
$this->assertTrue(file_exists($this->cacheFile), 'Cache file should exist');
$this->assertTrue(filesize($this->cacheFile) > 0, 'Cache file should be non-empty');
$this->removeCacheFile();
}
示例10: attach
public function attach()
{
if (!isset($this->name)) {
$this->name = Autoloader::uniqueName();
}
Autoloader::attach($this);
}
示例11: initialize
public static function initialize()
{
if (defined('TESTS_ENV') || self::is_dev()) {
ini_set('display_errors', 'on');
error_reporting(E_ALL);
} else {
ini_set('display_errors', 'off');
error_reporting(0);
}
require_once ROOT_PATH . DS . 'common' . DS . 'classes' . DS . 'autoloader.php';
Autoloader::init_autoload();
FileSystemHelper::init_dirs();
LIVR::defaultAutoTrim(true);
/**
* @var $system \System
*/
$system = static::get_class(\System::class);
$system->initialize();
/**
* @var $configuration Configuration
*/
$configuration = Application::get_class(Configuration::class);
$current_lang = $configuration->language;
defined('CURRENT_LANG') or define('CURRENT_LANG', $current_lang);
}
示例12: testUnregisterRegistersAutoloaderProperly
/**
* Test unregister method unregisters autoloader class and method properly.
*/
public function testUnregisterRegistersAutoloaderProperly()
{
$this->setUpAutoloaderWithStrategy();
$this->registerAutoloaderStrategyMock();
$this->autoloader->unregister();
$this->assertAutoloaderUnregistered();
}
示例13: testAutoloadValidGeodeticClass
public function testAutoloadValidGeodeticClass()
{
$className = 'Geodetic\\Angle';
$result = Autoloader::Load($className);
// Check that class has been loaded
$this->assertTrue(class_exists($className));
}
示例14: getPath
public static function getPath()
{
if (!self::$path) {
self::$path = realpath(dirname(__FILE__));
}
return self::$path;
}
示例15: GetInstance
public static function GetInstance()
{
if (!self::$_Instance) {
self::$_Instance = new self();
}
return self::$_Instance;
}