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

PHP Autoload\ClassLoader类代码示例

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

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



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

示例1: autoload

 /**
  * Autoloads all registered extension files with an instance of the app.
  *
  * @return void
  **/
 public function autoload($app)
 {
     $loader = new ClassLoader();
     $mapfile = $this->basefolder . '/vendor/composer/autoload_psr4.php';
     if (is_readable($mapfile)) {
         $map = (require $mapfile);
         foreach ($map as $namespace => $path) {
             $loader->setPsr4($namespace, $path);
         }
         $mapfile = $this->basefolder . '/vendor/composer/autoload_classmap.php';
         if (is_readable($mapfile)) {
             $map = (require $mapfile);
             $loader->addClassMap($map);
         }
         $loader->register();
     }
     $filepath = $this->basefolder . '/vendor/composer/autoload_files.php';
     if (is_readable($filepath)) {
         $files = (include $filepath);
         foreach ($files as $file) {
             try {
                 if (is_readable($file)) {
                     require $file;
                 }
             } catch (\Exception $e) {
                 $this->logInitFailure('Error importing extension class', $file, $e, Logger::ERROR);
             }
         }
     }
 }
开发者ID:ClemsB,项目名称:bolt,代码行数:35,代码来源:Extensions.php


示例2: createAppKernel

 /**
  * Creates RAD app kernel, which you can use to manage your app.
  *
  * Loads intl, swift and then requires/initializes/returns custom
  * app kernel.
  *
  * @param ClassLoader $loader      Composer class loader
  * @param string      $environment Environment name
  * @param Boolean     $debug       Debug mode?
  *
  * @return RadAppKernel
  */
 public static function createAppKernel(ClassLoader $loader, $environment, $debug)
 {
     require_once __DIR__ . '/RadAppKernel.php';
     if (null === self::$projectRootDir) {
         self::$projectRootDir = realpath(__DIR__ . '/../../../../../../..');
     }
     $autoloadIntl = function ($rootDir) use($loader) {
         if (!function_exists('intl_get_error_code')) {
             require_once $rootDir . '/vendor/symfony/symfony/src/' . 'Symfony/Component/Locale/Resources/stubs/functions.php';
             $loader->add(null, $rootDir . '/vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
         }
     };
     $autoloadSwift = function ($rootDir) use($loader) {
         require_once $rootDir . '/vendor/swiftmailer/swiftmailer/lib/classes/Swift.php';
         \Swift::registerAutoload($rootDir . '/vendor/swiftmailer/swiftmailer/lib/swift_init.php');
     };
     $loader->add(null, self::$projectRootDir . '/src');
     if (file_exists($custom = self::$projectRootDir . '/config/autoload.php')) {
         require $custom;
     } else {
         $autoloadIntl(self::$projectRootDir);
         $autoloadSwift(self::$projectRootDir);
     }
     return new \RadAppKernel($environment, $debug);
 }
开发者ID:ruian,项目名称:KnpRadBundle,代码行数:37,代码来源:RadKernel.php


示例3: init

 /**
  * Initializes Maam by generating new class files for all PHP files in the supplied sourcePath
  * and adds the new classmap to Composer's loader.
  *
  * @param ClassLoader $loader Composer's class loader.
  * @throws RuntimeException
  * @return void
  */
 public function init(ClassLoader $loader)
 {
     if ($this->getMode() === self::MODE_DEVELOPMENT) {
         $this->runGeneratorCommand();
     }
     $loader->addClassMap(require $this->getGenerationPath() . '/classmap.php');
 }
开发者ID:michaelmoussa,项目名称:maam,代码行数:15,代码来源:Maam.php


示例4: build

 /**
  * Builds internal request handling objects.
  *
  * @return $this
  */
 public function build()
 {
     if ($this->cache) {
         $loader = new ClassLoader();
         if ($this->apc) {
             $apcLoader = new ApcClassLoader(sha1('ReactServer'), $loader);
             $loader->unregister();
             $apcLoader->register(true);
         }
     }
     require_once $this->root_dir . '/AppKernel.php';
     define('KERNEL_ROOT', $this->root_dir);
     $kernel = new ReactKernel($this->env, $this->env === 'dev' ? true : false);
     $this->loop = Factory::create();
     // TODO make config for this part
     if (class_exists('\\Doctrine\\DBAL\\Driver\\PingableConnection')) {
         $this->loop->addPeriodicTimer(15, function () use($kernel) {
             foreach ($kernel->getContainer()->get('doctrine')->getConnections() as $connection) {
                 if ($connection instanceof \Doctrine\DBAL\Driver\PingableConnection) {
                     $connection->ping();
                 }
             }
         });
     }
     $this->socket = new SocketServer($this->loop);
     $http = new HttpServer($this->socket, $this->loop);
     $http->on('request', $this->handleRequest($kernel));
     return $this;
 }
开发者ID:itscaro,项目名称:react-bundle,代码行数:34,代码来源:Server.php


示例5: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     $classLoader = new ClassLoader();
     $classLoader->addPsr4('App\\', __DIR__ . '/Fixtures/src/App');
     $classLoader->addPsr4('Test\\', __DIR__ . '/Fixtures/src/Test');
     $classLoader->register();
 }
开发者ID:radphp,项目名称:radphp,代码行数:7,代码来源:EtcTest.php


示例6: loadClass

 /**
  * @param string $class
  * @param \Donquixote\HastyReflectionCommon\Canvas\ClassLoaderCanvas\ClassLoaderCanvasInterface $canvas
  */
 function loadClass($class, ClassLoaderCanvasInterface $canvas)
 {
     $file = $this->composerClassLoader->findFile($class);
     if (FALSE === $file) {
         return;
     }
     $canvas->includeOnce($file);
 }
开发者ID:donquixote,项目名称:hasty-reflection-common,代码行数:12,代码来源:ClassLoader_Composer.php


示例7: getLoader

 /**
  * {@inheritDoc}
  */
 public function getLoader()
 {
     $loader = new ClassLoader();
     foreach ($this->information as $prefix => $paths) {
         $loader->add($prefix, array_map(array($this, 'prependPathWithBaseDir'), (array) $paths));
     }
     return array($loader, 'loadClass');
 }
开发者ID:phpcq,项目名称:autoload-validation,代码行数:11,代码来源:Psr0Validator.php


示例8: register

 /**
  * Register's the annotation driver for the passed configuration.
  *
  * @param \AppserverIo\Appserver\Core\Api\Node\AnnotationRegistryNodeInterface $annotationRegistry The configuration node
  *
  * @return void
  */
 public function register(AnnotationRegistryNodeInterface $annotationRegistry)
 {
     // initialize the composer class loader
     $classLoader = new ClassLoader();
     $classLoader->addPsr4($annotationRegistry->getNamespace(), $annotationRegistry->getDirectoriesAsArray());
     // register the class loader to load annotations
     AnnotationRegistry::registerLoader(array($classLoader, 'loadClass'));
 }
开发者ID:appserver-io,项目名称:appserver,代码行数:15,代码来源:Psr4AnnotationRegistry.php


示例9: __construct

 /**
  * Construct
  *
  * @param ClassLoader $loader Loader
  *
  * @throws Exception
  */
 public function __construct(ClassLoader $loader)
 {
     if (empty($loader->getClassMap())) {
         throw new Exception('You are required to run: composer dump-autoload -o', Http::STATUS_CODE_404);
     }
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     $this->directoryClassLoader($loader, self::getAppDir() . DS . 'modules');
     $this->setModules(Loader::load($loader));
     $this->directoryClassLoader($loader, self::getAppDir() . DS . 'libraries');
     $routing = array();
     foreach ($this->getModules() as $mod) {
         // Get routing from menus
         if (method_exists($mod, 'menus')) {
             $menus = array();
             foreach ($mod->menus() as $name => $menu) {
                 foreach ($menu as $key => $value) {
                     $routing['GET'] = array_merge_recursive($value->getRoutesRecursive(), $routing);
                     if ($value instanceof Menu) {
                         $menus[$name][$key] = $value->toArray();
                     }
                 }
             }
             $this->menus = array_replace_recursive($menus, $this->menus);
         }
         // Get additional routing
         if (method_exists($mod, 'routes')) {
             foreach ($mod->routes() as $method => $route) {
                 foreach ($route as $key => $value) {
                     if (key_exists(strtoupper($method), $routing) && key_exists($value, $routing[strtoupper($method)])) {
                         $routing[strtoupper($method)][$value] = array_merge_recursive($routing[strtoupper($method)][$value], array($key));
                     } else {
                         $routing[strtoupper($method)][$value] = array($key);
                     }
                 }
             }
         }
         self::callGlobalEvent($mod, 'bootstrap');
     }
     // Add extra routes to module routing
     foreach ($routing as $method => $routes) {
         foreach ($routes as $action => $route) {
             if (!empty($route)) {
                 foreach ($this->getModules() as $module) {
                     foreach ($module->getRoutes() as &$urls) {
                         if ($urls->getRequestMethod() === $method) {
                             if (in_array($action, $urls->getUrls())) {
                                 $urls->setUrls(array_merge($urls->getUrls(), $route));
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:phpforge,项目名称:application,代码行数:64,代码来源:Application.php


示例10: __construct

 public function __construct()
 {
     parent::__construct('fancy_research_links');
     $this->directory = WT_MODULES_DIR . $this->getName();
     // register the namespace
     $loader = new ClassLoader();
     $loader->addPsr4('JustCarmen\\WebtreesAddOns\\FancyResearchLinks\\', WT_MODULES_DIR . $this->getName() . '/app');
     $loader->register();
 }
开发者ID:bschwede,项目名称:fancy_research_links,代码行数:9,代码来源:module.php


示例11: __construct

 /** {@inheritdoc} */
 public function __construct()
 {
     parent::__construct();
     $this->directory = WT_MODULES_DIR . $this->getName();
     // register the namespaces
     $loader = new ClassLoader();
     $loader->addPsr4('JustCarmen\\WebtreesAddOns\\FancyTreeviewPdf\\', $this->directory . '/app');
     $loader->register();
 }
开发者ID:JustCarmen,项目名称:fancy_treeview_pdf,代码行数:10,代码来源:module.php


示例12: registerLoader

 /**
  * Register classloader for extension
  *
  * @return \Composer\Autoload\ClassLoader
  */
 protected function registerLoader()
 {
     $classpath = __DIR__;
     $nsprefix = __NAMESPACE__ . '\\';
     $loader = new ClassLoader();
     $loader->addPsr4($nsprefix, $classpath);
     $loader->register();
     return $loader;
 }
开发者ID:Hoplite-Software,项目名称:observatory,代码行数:14,代码来源:ExtensionHelper.php


示例13: __construct

 public function __construct()
 {
     parent::__construct('modulename');
     $this->directory = WT_MODULES_DIR . $this->getName();
     $this->action = Filter::get('mod_action');
     // register the namespaces
     $loader = new ClassLoader();
     $loader->addPsr4('vendor\\WebtreesModules\\modulename\\', $this->directory);
     $loader->register();
 }
开发者ID:bmhm,项目名称:webtrees-module-skeleton,代码行数:10,代码来源:module.php


示例14: setUp

 protected function setUp()
 {
     $filesystem = new Filesystem();
     $filesystem->remove(__DIR__ . '/Fixtures/tmp');
     $filesystem->mirror(__DIR__ . '/Fixtures/template', __DIR__ . '/Fixtures/tmp');
     $loader = new ClassLoader();
     $loader->addPsr4('Fixtures\\Maba\\Bundle\\', __DIR__ . '/Fixtures/tmp/src');
     $loader->addPsr4('Fixtures\\Maba\\', __DIR__ . '/Fixtures/tmp/app');
     $loader->register(true);
     static::bootKernel();
 }
开发者ID:mariusbalcytis,项目名称:webpack-migration-bundle,代码行数:11,代码来源:FunctionalTest.php


示例15: registerClassMaps

 public function registerClassMaps($classMap)
 {
     if (!$classMap) {
         return;
     }
     if (!is_array($classMap)) {
         $classMap = [$classMap];
     }
     $loader = new ClassLoader();
     $loader->addClassMap($classMap);
     $loader->register(true);
 }
开发者ID:pckg,项目名称:framework,代码行数:12,代码来源:Registrator.php


示例16: decorate

 public function decorate(ClassLoader $classLoader)
 {
     $standards = $this->standardFinder->getStandards();
     foreach ($standards as $stadardName => $standardRuleset) {
         if ($this->isDefaultStandard($stadardName)) {
             continue;
         }
         $standardNamespace = $this->detectStandardNamespaceFromStandardName($stadardName);
         $standardDir = dirname($standardRuleset);
         $classLoader->addPsr4($standardNamespace . '\\', $standardDir . DIRECTORY_SEPARATOR . $standardNamespace);
     }
 }
开发者ID:symplify,项目名称:php7_codesniffer,代码行数:12,代码来源:ClassLoaderDecorator.php


示例17: __construct

 /** {@inheritdoc} */
 public function __construct()
 {
     parent::__construct('fancy_treeview');
     $this->tree = $this->tree();
     $this->tree_id = $this->tree->getTreeId();
     $this->directory = WT_MODULES_DIR . $this->getName();
     $this->action = Filter::get('mod_action');
     // register the namespaces
     $loader = new ClassLoader();
     $loader->addPsr4('JustCarmen\\WebtreesAddOns\\FancyTreeview\\', $this->directory . '/src');
     $loader->register();
 }
开发者ID:bxbroze,项目名称:webtrees,代码行数:13,代码来源:module.php


示例18: init

 /**
  * @param Container $container
  * @param ClassLoader $classLoader
  */
 public function init(Container $container, ClassLoader $classLoader)
 {
     foreach (self::$extensions as $extension) {
         if ($this->validate($extension)) {
             $classLoader->addPsr4($extension->getNamespace() . '\\', $extension->getPath());
             $configuration = $this->getConfigurationFromExtension($extension);
             if ($configuration) {
                 $container->configurations->add($configuration);
             }
         }
     }
 }
开发者ID:jigoshop,项目名称:Jigoshop2,代码行数:16,代码来源:Extensions.php


示例19: loadClass

 /**
  * Loads the given class or interface.
  *
  * @param   string  $class  The name of the class
  *
  * @return  boolean|null  True if loaded, null otherwise
  *
  * @since   3.4
  */
 public function loadClass($class)
 {
     if ($result = $this->loader->loadClass($class)) {
         JLoader::applyAliasFor($class);
     }
     return $result;
 }
开发者ID:jasonrgd,项目名称:Digital-Publishing-Platform-Joomla,代码行数:16,代码来源:loader.php


示例20: testInitializerSkipsGenerationInProductionMode

 public function testInitializerSkipsGenerationInProductionMode()
 {
     $this->maam->init($this->loader);
     $classMap = $this->loader->getClassMap();
     $this->assertArrayHasKey('someclass', $classMap);
     $this->assertSame('somefile', $classMap['someclass']);
 }
开发者ID:michaelmoussa,项目名称:maam,代码行数:7,代码来源:MaamTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP DependencyResolver\Pool类代码示例发布时间:2022-05-23
下一篇:
PHP Composer\Installer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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