• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ClassLoader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ClassLoader的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader类的具体用法?PHP ClassLoader怎么用?PHP ClassLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ClassLoader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testLoadClass

 public function testLoadClass()
 {
     $loader = new ClassLoader();
     $loader->register();
     $this->assertEquals(true, class_exists("Controller"));
     $this->assertEquals(false, class_exists("MyController"));
 }
开发者ID:remore,项目名称:gratuitous-framework,代码行数:7,代码来源:ClassLoaderTest.php


示例2: getLoader

 public static function getLoader()
 {
     if (null !== self::$loader) {
         return self::$loader;
     }
     spl_autoload_register(array('\\Composer\\Autoload\\Initializer', 'loadClassLoader'), true, true);
     self::$loader = $loader = new ClassLoader();
     spl_autoload_unregister(array('\\Composer\\Autoload\\Initializer', 'loadClassLoader'));
     $vendorDir = dirname(__DIR__);
     $baseDir = dirname($vendorDir);
     $map = (require __DIR__ . '/autoload_namespaces.php');
     foreach ($map as $namespace => $path) {
         $loader->set($namespace, $path);
     }
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register(true);
     $includeFiles = (require __DIR__ . '/autoload_files.php');
     foreach ($includeFiles as $file) {
         require $file;
     }
     return $loader;
 }
开发者ID:chaoyanjie,项目名称:MonkeyPHP,代码行数:25,代码来源:Initializer.php


示例3: __construct

 public function __construct(ClassLoader $aClassLoader, $sNamespace = null, $nPriority = Package::all)
 {
     $arrClasses = array();
     foreach ($aClassLoader->packageIterator($nPriority) as $aPackage) {
         if ($sNamespace) {
             $sPackageNamespace = $aPackage->ns();
             if ($sNamespace == $sPackageNamespace) {
                 $sSubNs = null;
             } else {
                 if (strpos($sNamespace, $sPackageNamespace . '\\') === 0) {
                     $sSubNs = substr($sNamespace, strlen($sPackageNamespace) + 1);
                 } else {
                     continue;
                 }
             }
         } else {
             $sSubNs = null;
         }
         foreach ($aPackage->classIterator($sSubNs) as $sClass) {
             if (!in_array($sClass, $arrClasses)) {
                 $arrClasses[] = $sClass;
             }
         }
     }
     sort($arrClasses);
     parent::__construct($arrClasses);
 }
开发者ID:JeCat,项目名称:framework,代码行数:27,代码来源:ClassIterator.php


示例4: getLoader

 public static function getLoader()
 {
     if (null !== self::$loader) {
         return self::$loader;
     }
     spl_autoload_register(array('AutoloaderInit', 'loadClassLoader'), true, true);
     self::$loader = $loader = new ClassLoader();
     spl_autoload_unregister(array('AutoloaderInit', 'loadClassLoader'));
     /* $map = require __DIR__ . '/autoload_namespaces.php';
        foreach ($map as $namespace => $path) {
            $loader->set($namespace, $path);
        }*/
     /* $map = require __DIR__ . '/autoload_psr4.php';
        foreach ($map as $namespace => $path) {
            $loader->setPsr4($namespace, $path);
        }*/
     $includeFiles = (require __DIR__ . '/autoload_files.php');
     foreach ($includeFiles as $file) {
         composerRequire($file);
     }
     $classMap = (require __DIR__ . '/autoload_classmap.php');
     if ($classMap) {
         $loader->addClassMap($classMap);
     }
     $loader->register(true);
     return $loader;
 }
开发者ID:xuyintao,项目名称:web01,代码行数:27,代码来源:autoload_real.php


示例5: make

 /**
  * Makes autoloader.
  *
  * @return ClassLoader The class loader
  */
 public static function make()
 {
     if (!static::$loader) {
         $loader = new ClassLoader();
         $loader->register();
         static::$loader = $loader;
     }
     return static::$loader;
 }
开发者ID:easy-system,项目名称:es-loader,代码行数:14,代码来源:AutoloaderFactory.php


示例6: configure

 /**
  * Add autoload configuration of packages managed by Composer
  *
  * @param ClassLoader $classLoader   class loader instance to configure
  * @param string      $vendorDirPath path to the vendor directory without trailing slash
  */
 public static function configure(ClassLoader $classLoader, $vendorDirPath)
 {
     $composerBasePath = $vendorDirPath . '/composer/';
     $classLoader->addClassMap(include $composerBasePath . 'autoload_classmap.php');
     $classLoader->addPrefixes(include $composerBasePath . 'autoload_psr4.php');
     $classLoader->addPrefixes(include $composerBasePath . 'autoload_namespaces.php', ClassLoader::PSR0);
     foreach (include $composerBasePath . 'autoload_files.php' as $file) {
         require $file;
     }
 }
开发者ID:kuria,项目名称:class-loader,代码行数:16,代码来源:ComposerBridge.php


示例7: init

function init()
{
    $loader = new ClassLoader();
    $map = (require __DIR__ . '/autoload_namespaces.php');
    foreach ($map as $namespace => $path) {
        $loader->add($namespace, $path);
    }
    $loader->register();
    return $loader;
}
开发者ID:radzikowski,项目名称:CraftyComponents,代码行数:10,代码来源:autoload.php


示例8: registerClassLoader

 public function registerClassLoader()
 {
     if (!interface_exists("ClassLoader", false)) {
         require \pocketmine\PATH . "src/spl/ClassLoader.php";
         require \pocketmine\PATH . "src/spl/BaseClassLoader.php";
         require \pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php";
     }
     if ($this->classLoader !== null) {
         $this->classLoader->register(true);
     }
 }
开发者ID:xxFlare,项目名称:PocketMine-MP,代码行数:11,代码来源:Worker.php


示例9: getLoader

 /**
  * Constructs and returns the class loader.
  *
  * @param  array $map Array containing path to each namespace.
  *
  * @return ClassLoader
  */
 public static function getLoader(array $map)
 {
     if (null !== self::$loader) {
         return self::$loader;
     }
     self::$loader = $loader = new ClassLoader();
     foreach ($map as $namespace => $path) {
         $loader->set($namespace, $path);
     }
     $loader->register(true);
     return $loader;
 }
开发者ID:FuhrerMalkovich,项目名称:Blogpost,代码行数:19,代码来源:autoload.php


示例10: getLoader

 public static function getLoader()
 {
     if (null !== self::$loader) {
         return self::$loader;
     }
     spl_autoload_register(array('ComposerAutoLoaderInit', 'loadClassLoader'), true, true);
     self::$loader = $loader = new ClassLoader();
     spl_autoload_unregister(array('ComposerAutoLoaderInit', 'loadClassLoader'));
     $class_map = (require dirname(__FILE__) . '/autoload_classmap.php');
     if ($class_map) {
         $loader->addClassMap($class_map);
     }
     $loader->register();
     return $loader;
 }
开发者ID:bayuexiong,项目名称:simple-composer,代码行数:15,代码来源:autoload_real.php


示例11: start

 /**
  * Loads all aspects from configured paths and activates class loader.
  */
 public function start()
 {
     $classLoader = new ClassLoader();
     $aspectLoader = AspectLoader::getLoader();
     $registry = Registry::getRegistry();
     foreach ($this->getAspectPaths() as $aspectPath) {
         $aspectLoader->loadAspects($aspectPath);
     }
     $aspectLoader->activate();
     $aspectLoader->deactivate();
     foreach ($aspectLoader->getAspects() as $aspectClass) {
         $registry->parseClass($aspectClass);
     }
     $classLoader->activate();
 }
开发者ID:mneudert,项目名称:guise,代码行数:18,代码来源:Guise.php


示例12: __static

    static function __static()
    {
        // For singletonInstance test
        ClassLoader::defineClass('net.xp_framework.unittest.core.AnonymousSingleton', 'lang.Object', array(), '{
        protected static $instance= NULL;

        static function getInstance() {
          if (!isset(self::$instance)) self::$instance= new AnonymousSingleton();
          return self::$instance;
        }
      }');
        // For returnNewObject and returnNewObjectViaReflection tests
        ClassLoader::defineClass('net.xp_framework.unittest.core.AnonymousList', 'lang.Object', array(), '{
        function __construct() {
          ReferencesTest::registry("list", $this);
        }
      }');
        ClassLoader::defineClass('net.xp_framework.unittest.core.AnonymousFactory', 'lang.Object', array(), '{
        static function factory() {
          return new AnonymousList();
        }
      }');
        ClassLoader::defineClass('net.xp_framework.unittest.core.AnonymousNewInstanceFactory', 'lang.Object', array(), '{
        static function factory() {
          return XPClass::forName("net.xp_framework.unittest.core.AnonymousList")->newInstance();
        }
      }');
    }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:28,代码来源:ReferencesTest.class.php


示例13: run

 public static function run($accessString)
 {
     if (empty($accessString)) {
         return true;
     }
     if (preg_match_all('/([\\w\\.]+)(?:\\(([\\w\\.]*)(?:\\/(\\w*))?\\))?,?/', $accessString, $roles)) {
         ClassLoader::import('application.model.user.SessionUser');
         $currentUser = SessionUser::getUser();
         $controller = Controller::getCurrentController();
         $rolesParser = $controller->getRoles();
         $currentControllerName = $controller->getRequest()->getControllerName();
         $currentActionName = $controller->getRequest()->getActionName();
         $rolesCount = count($roles[0]);
         for ($i = 0; $i < $rolesCount; $i++) {
             $roleString = $roles[0][$i];
             $roleName = $roles[1][$i];
             $roleControllerName = empty($roles[3][$i]) ? $currentControllerName : $roles[2][$i];
             $roleActionName = empty($roles[3][$i]) ? empty($roles[2][$i]) ? $currentActionName : $roles[2][$i] : $currentActionName;
             if ($roleControllerName == $currentControllerName && $roleActionName == $currentActionName) {
                 $aRoleName = $rolesParser->getRole($roleActionName);
                 if ($currentUser->hasAccess($aRoleName) && $currentUser->hasAccess($roleName)) {
                     return true;
                 }
             }
         }
         return false;
     }
     throw new ApplicationException('Access string ("' . $accessString . '") has illegal format');
 }
开发者ID:saiber,项目名称:livecart,代码行数:29,代码来源:AccessStringParser.php


示例14: getInstance

 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new ClassLoader();
     }
     return self::$instance;
 }
开发者ID:BackupTheBerlios,项目名称:frameorm-svn,代码行数:7,代码来源:autoload.php


示例15: deployBean

 /**
  * Deploy
  *
  * @param   remote.server.deploy.Deployable deployment
  */
 public function deployBean($deployment)
 {
     if ($deployment instanceof IncompleteDeployment) {
         throw new DeployException('Incomplete deployment originating from ' . $deployment->origin, $deployment->cause);
     }
     $this->cat && $this->cat->info($this->getClassName(), 'Begin deployment of', $deployment);
     // Register beans classloader. This classloader must be put at the beginning
     // to prevent loading of the home interface not implmenenting BeanInterface
     $cl = $deployment->getClassLoader();
     ClassLoader::getDefault()->registerLoader($cl, TRUE);
     $impl = $cl->loadClass($deployment->getImplementation());
     $interface = $cl->loadClass($deployment->getInterface());
     $directoryName = $deployment->getDirectoryName();
     // Fetch naming directory
     $directory = NamingDirectory::getInstance();
     // Create beanContainer
     // TBI: Check which kind of bean container has to be created
     $beanContainer = StatelessSessionBeanContainer::forClass($impl);
     $this->cat && $beanContainer->setTrace($this->cat);
     // Create invocation handler
     $invocationHandler = new ContainerInvocationHandler();
     $invocationHandler->setContainer($beanContainer);
     // Now bind into directory
     $directory->bind($directoryName, Proxy::newProxyInstance($cl, array($interface), $invocationHandler));
     $this->cat && $this->cat->info($this->getClassName(), 'End deployment of', $impl->getName(), 'with ND entry', $directoryName);
     return $beanContainer;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:32,代码来源:Deployer.class.php


示例16: setUp

 /**
  * Sets up test case
  *
  */
 public function setUp()
 {
     try {
         $this->classname = $this->testClassName();
         $this->interfacename = $this->testClassName('I');
     } catch (IllegalStateException $e) {
         throw new PrerequisitesNotMetError($e->getMessage());
     }
     // Create an archive
     $this->tempfile = new TempFile($this->name);
     $archive = new Archive($this->tempfile);
     $archive->open(ARCHIVE_CREATE);
     $this->add($archive, $this->classname, '
     uses("util.Comparator", "' . $this->interfacename . '");
     class ' . $this->classname . ' extends Object implements ' . $this->interfacename . ', Comparator { 
       public function compare($a, $b) {
         return strcmp($a, $b);
       }
     }
   ');
     $this->add($archive, $this->interfacename, 'interface ' . $this->interfacename . ' { } ');
     $archive->create();
     // Setup classloader
     $this->classloader = new ArchiveClassLoader($archive);
     ClassLoader::getDefault()->registerLoader($this->classloader, TRUE);
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:30,代码来源:ArchiveClassLoaderTest.class.php


示例17: testSimpleImport

 public function testSimpleImport()
 {
     $lv = ActiveRecordModel::getNewInstance('Language');
     $lv->setID('xx');
     $lv->save();
     $profile = new CsvImportProfile('Product');
     $profile->setField(0, 'Product.sku');
     $profile->setField(1, 'Product.name', array('language' => 'en'));
     $profile->setField(2, 'Product.name', array('language' => 'xx'));
     $profile->setField(3, 'Product.shippingWeight');
     $profile->setParam('delimiter', ';');
     $csvFile = ClassLoader::getRealPath('cache.') . 'testDataImport.csv';
     file_put_contents($csvFile, 'test; "Test Product"; "Parbaudes Produkts"; 15' . "\n" . 'another; "Another Test"; "Vel Viens"; 12.44');
     $import = new ProductImport($this->getApplication());
     $csv = $profile->getCsvFile($csvFile);
     $cnt = $import->importFile($csv, $profile);
     $this->assertEquals($cnt, 2);
     $test = Product::getInstanceBySKU('test');
     $this->assertTrue($test instanceof Product);
     $this->assertEquals($test->shippingWeight->get(), '15');
     $this->assertEquals($test->getValueByLang('name', 'en'), 'Test Product');
     $another = Product::getInstanceBySKU('another');
     $this->assertEquals($another->getValueByLang('name', 'xx'), 'Vel Viens');
     unlink($csvFile);
 }
开发者ID:saiber,项目名称:livecart,代码行数:25,代码来源:ProductImportTest.php


示例18: load_imports

 /**
  * Loads all the files that the environment requires
  */
 public static function load_imports()
 {
     require_once PATH_TO_ROOT . '/kernel/framework/helper/deprecated_helper.inc.php';
     include_once PATH_TO_ROOT . '/kernel/framework/core/ClassLoader.class.php';
     ClassLoader::init_autoload();
     AppContext::init_bench();
 }
开发者ID:AroundPBT,项目名称:PHPBoost,代码行数:10,代码来源:Environment.class.php


示例19: dummyConnectionClass

    public static function dummyConnectionClass()
    {
        self::$conn = ClassLoader::defineClass('RestClientExecutionTest_Connection', 'peer.http.HttpConnection', array(), '{
        protected $result= NULL;
        protected $exception= NULL;

        public function __construct($status, $body, $headers) {
          parent::__construct("http://test");
          if ($status instanceof Throwable) {
            $this->exception= $status;
          } else {
            $this->result= "HTTP/1.1 ".$status."\\r\\n";
            foreach ($headers as $name => $value) {
              $this->result.= $name.": ".$value."\\r\\n";
            }
            $this->result.= "\\r\\n".$body;
          }
        }
        
        public function send(HttpRequest $request) {
          if ($this->exception) {
            throw $this->exception;
          } else {
            return new HttpResponse(new MemoryInputStream($this->result));
          }
        }
      }');
    }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:28,代码来源:RestClientExecutionTest.class.php


示例20: getInstance

 /**
  * 
  * @return ClassLoader
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
开发者ID:RandomUsernameHere,项目名称:megainfo-corporate-cms,代码行数:11,代码来源:ClassLoader.php



注:本文中的ClassLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ClassRegistry类代码示例发布时间:2022-05-20
下一篇:
PHP ClassInfo类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap