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


PHP Autoload\ClassLoader類代碼示例

本文整理匯總了PHP中Composer\Autoload\ClassLoader的典型用法代碼示例。如果您正苦於以下問題:PHP ClassLoader類的具體用法?PHP ClassLoader怎麽用?PHP ClassLoader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ClassLoader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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

示例14: 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

示例15: __destruct

 public function __destruct()
 {
     if ($this->loader) {
         $this->loader->unregister();
         $this->loader = NULL;
     }
 }
開發者ID:konadave,項目名稱:civicrm-core,代碼行數:7,代碼來源:ClassLoader.php


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