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


PHP Autoloader類代碼示例

本文整理匯總了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();
     }
 }
開發者ID:RobertoMalatesta,項目名稱:neard,代碼行數:29,代碼來源:class.bootstrap.php

示例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);
 }
開發者ID:xxdf,項目名稱:showtimes,代碼行數:13,代碼來源:TestParser.php

示例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);
 }
開發者ID:naderman,項目名稱:pflow,代碼行數:16,代碼來源:AutoloaderTest.php

示例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']));
 }
開發者ID:nilsabegg,項目名稱:rueckgrat,代碼行數:22,代碼來源:Bootloader.php

示例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();
 }
開發者ID:xdbas,項目名稱:restwork,代碼行數:18,代碼來源:Application.php

示例6: LoadComponents

 public static function LoadComponents()
 {
     $Components = array('Classes');
     foreach ($Components as $Component) {
         Autoloader::LoadOrder($Component);
     }
 }
開發者ID:anonymous33rus,項目名稱:FreedomCore,代碼行數:7,代碼來源:Autoloader.Class.php

示例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;
 }
開發者ID:lagdo,項目名稱:xajax-core,代碼行數:41,代碼來源:Manager.php

示例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;
 }
開發者ID:takawasitobi,項目名稱:pembit,代碼行數:40,代碼來源:php.php

示例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();
 }
開發者ID:jmhobbs,項目名稱:MkLst,代碼行數:7,代碼來源:TestAutoloader.class.php

示例10: attach

 public function attach()
 {
     if (!isset($this->name)) {
         $this->name = Autoloader::uniqueName();
     }
     Autoloader::attach($this);
 }
開發者ID:jjanes,項目名稱:Amber-PHP-Application-Framework,代碼行數:7,代碼來源:system.autoloader.php

示例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);
 }
開發者ID:one-more,項目名稱:peach_framework,代碼行數:25,代碼來源:application.php

示例12: testUnregisterRegistersAutoloaderProperly

 /**
  * Test unregister method unregisters autoloader class and method properly.
  */
 public function testUnregisterRegistersAutoloaderProperly()
 {
     $this->setUpAutoloaderWithStrategy();
     $this->registerAutoloaderStrategyMock();
     $this->autoloader->unregister();
     $this->assertAutoloaderUnregistered();
 }
開發者ID:exorg,項目名稱:autoloader,代碼行數:10,代碼來源:AutoloaderTest.php

示例13: testAutoloadValidGeodeticClass

 public function testAutoloadValidGeodeticClass()
 {
     $className = 'Geodetic\\Angle';
     $result = Autoloader::Load($className);
     //    Check that class has been loaded
     $this->assertTrue(class_exists($className));
 }
開發者ID:markbaker,項目名稱:phpgeodetic,代碼行數:7,代碼來源:AutoloaderTest.php

示例14: getPath

 public static function getPath()
 {
     if (!self::$path) {
         self::$path = realpath(dirname(__FILE__));
     }
     return self::$path;
 }
開發者ID:tin-cat,項目名稱:redis-info,代碼行數:7,代碼來源:Autoloader.php

示例15: GetInstance

 public static function GetInstance()
 {
     if (!self::$_Instance) {
         self::$_Instance = new self();
     }
     return self::$_Instance;
 }
開發者ID:nvadim,項目名稱:ArrayTree,代碼行數:7,代碼來源:Autoloader.class.php


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