/** * Constructor * * @param KernelInterface $kernel */ public function __construct(KernelInterface $kernel) { // register logging hydrators class loader $loader = new ClassLoader(); $loader->addPrefix('OroLoggingHydrator\\', $kernel->getCacheDir() . DIRECTORY_SEPARATOR . 'oro_entities'); $loader->register(); }
/** * @dataProvider getLoadClassNamespaceCollisionTests */ public function testLoadClassNamespaceCollision($namespaces, $className, $message) { $loader = new ClassLoader(); $loader->addPrefixes($namespaces); $loader->loadClass($className); $this->assertTrue(class_exists($className), $message); }
public function provideLegacyClassNotFoundData() { $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); $prefixes = array('Symfony\\Component\\Debug\\Exception\\' => realpath(__DIR__ . '/../../Exception')); $symfonyAutoloader = new SymfonyClassLoader(); $symfonyAutoloader->addPrefixes($prefixes); return array(array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?", array($symfonyAutoloader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for another namespace?", function ($className) { /* do nothing here */ })); }
public function provideClassNotFoundData() { $prefixes = array('Symfony\\Component\\Debug\\Exception\\' => realpath(__DIR__ . '/../../Exception')); $symfonyAutoloader = new SymfonyClassLoader(); $symfonyAutoloader->addPrefixes($prefixes); $debugClassLoader = new DebugClassLoader(array($symfonyAutoloader, 'loadClass')); return array(array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'WhizBangFactory\' not found'), "Attempted to load class \"WhizBangFactory\" from the global namespace.\nDid you forget a \"use\" statement?"), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\WhizBangFactory\' not found'), "Attempted to load class \"WhizBangFactory\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for another namespace?"), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from the global namespace.\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?"), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'PEARClass\' not found'), "Attempted to load class \"PEARClass\" from the global namespace.\nDid you forget a \"use\" statement for \"Symfony_Component_Debug_Tests_Fixtures_PEARClass\"?"), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?"), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?", array($symfonyAutoloader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for \"Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException\"?", array($debugClassLoader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), "Attempted to load class \"UndefinedFunctionException\" from namespace \"Foo\\Bar\".\nDid you forget a \"use\" statement for another namespace?", function ($className) { /* do nothing here */ })); }
public function provideClassNotFoundData() { $prefixes = array('Symfony\\Component\\Debug\\Exception\\' => realpath(__DIR__ . '/../../Exception')); $symfonyAutoloader = new SymfonyClassLoader(); $symfonyAutoloader->addPrefixes($prefixes); $symfonyUniversalClassLoader = new SymfonyUniversalClassLoader(); $symfonyUniversalClassLoader->registerPrefixes($prefixes); return array(array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'WhizBangFactory\' not found'), 'Attempted to load class "WhizBangFactory" from the global namespace in foo.php line 12. Did you forget a use statement for this class?'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\WhizBangFactory\' not found'), 'Attempted to load class "WhizBangFactory" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace?'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'PEARClass\' not found'), 'Attempted to load class "PEARClass" from the global namespace in foo.php line 12. Did you forget a use statement for this class? Perhaps you need to add a use statement for one of the following: Symfony_Component_Debug_Tests_Fixtures_PEARClass.'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.'), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.', array($symfonyAutoloader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace? Perhaps you need to add a use statement for one of the following: Symfony\\Component\\Debug\\Exception\\UndefinedFunctionException.', array($symfonyUniversalClassLoader, 'loadClass')), array(array('type' => 1, 'line' => 12, 'file' => 'foo.php', 'message' => 'Class \'Foo\\Bar\\UndefinedFunctionException\' not found'), 'Attempted to load class "UndefinedFunctionException" from namespace "Foo\\Bar" in foo.php line 12. Do you need to "use" it from another namespace?', function ($className) { /* do nothing here */ })); }
/** * Check for composer in Namespace * and include via phar if possible */ public static function checkComposer($pathToComposer = null) { if (!class_exists('Composer\\Factory')) { if (false === ($pathToComposer = self::whichComposer($pathToComposer))) { throw new \RuntimeException("Could not find composer.phar"); } \Phar::loadPhar($pathToComposer, 'composer.phar'); $loader = new ClassLoader(); $namespaces = (include "phar://composer.phar/vendor/composer/autoload_namespaces.php"); $loader->addPrefixes(array_merge(array('Composer' => "phar://composer.phar/src/"), $namespaces)); $loader->register(true); } }
public function initialize($extensionClass, $args = null) { if (!class_exists($extensionClass)) { if (true !== $this->classLoader->loadClass($extensionClass)) { throw new \InvalidArgumentException(sprintf("%s is not valid class.", $extensionClass)); } } $extensionReflection = new \ReflectionClass($extensionClass); $extension = is_array($args) && !empty($args) ? $extensionReflection->newInstanceArgs($args) : $extensionReflection->newInstance(); if (!$extension instanceof Extension) { throw new \InvalidArgumentException(sprintf("Class \"%s\" should be an instance of Coduo\\TuTu\\Extension", $extensionClass)); } return $extension; }
/** * Finds a file by class name while caching lookups to APC. * * @param string $class A class name to resolve to file * * @return string|null */ public function findFile($class) { if (false === ($file = apc_fetch($this->prefix . $class))) { apc_store($this->prefix . $class, $file = $this->decorated->findFile($class)); } return $file; }
/** * Finds a file by class name while caching lookups to WinCache. * * @param string $class A class name to resolve to file * * @return string|null */ public function findFile($class) { if (false === ($file = wincache_ucache_get($this->prefix . $class))) { wincache_ucache_set($this->prefix . $class, $file = $this->decorated->findFile($class), 0); } return $file; }
/** * Finds a file by class name while caching lookups to APC. * * @param string $class A class name to resolve to file * * @return string|null */ public function findFile($class) { $file = apc_fetch($this->prefix . $class); if (false === $file) { $file = $this->decorated->findFile($class); if (strlen($file) > $this->base_len && substr_compare($file, $this->base, 0, $this->base_len) == 0) { apc_store($this->prefix . $class, substr($file, $this->base_len)); } } else { $file = $this->base . $file; } return $file; }
/** * Finds file to store a class. * * @param string $class * * @return string * * @throws ContextNotFoundException If class file could not be determined */ private function findClassFile($class) { list($classpath, $classname) = $this->findClasspathAndClass($class); $classpath .= str_replace('_', DIRECTORY_SEPARATOR, $classname) . '.php'; foreach ($this->autoloader->getPrefixes() as $prefix => $dirs) { if (0 === strpos($class, $prefix)) { return current($dirs) . DIRECTORY_SEPARATOR . $classpath; } } if ($dirs = $this->autoloader->getFallbackDirs()) { return current($dirs) . DIRECTORY_SEPARATOR . $classpath; } throw new ContextNotFoundException(sprintf('Could not find where to put "%s" class. Have you configured autoloader properly?', $class), $class); }
/** * {@inheritdoc} */ public function buildDefaultConfiguration($resourceName = null, OutputInterface $output = null) { $this->setBundle($resourceName); $this->output = $output; //Model directory if (!$this->configuration['directory']) { $this->configuration['directory'] = $this->bundle->getPath() . '/Form/Type'; } //Model namespace if (!$this->configuration['namespace']) { $this->configuration['namespace'] = $this->bundle->getNamespace() . '\\Form\\Type'; } if (!$this->configuration['path']) { $loader = new ClassLoader(); $loader->setUseIncludePath(true); $namespace = $this->registry->getAliasNamespace($this->bundle->getName()) . '\\' . $this->model; $test = new $namespace(); $reflector = new \ReflectionClass(get_class($test)); $entity = $loader->findFile(dirname($reflector->getFileName()) . '\\' . $this->model); $this->configuration['path'] = $entity; } $this->setSkeletonDirs($this->getSkeletonDirs($this->bundle)); $this->_initialized = true; }
* Created by PhpStorm. * User: dima * Date: 17.09.15 * Time: 9:27 */ namespace { require_once __DIR__ . '/vendor/autoload.php'; use Dima\Legacy\TestClass as TestLoadedByMap; use Dima\Test as TestPsr0; use Symfony\Component\ClassLoader\ClassLoader; use Symfony\Component\ClassLoader\ClassMapGenerator; use Symfony\Component\ClassLoader\MapClassLoader; use Symfony\Component\ClassLoader\Psr4ClassLoader; use Symfony\Component\ClassLoader\XcacheClassLoader; use DG\SymfonyCert\Controller\HomeController; $psr0Loader = new ClassLoader(); $psr0Loader->addPrefix('Dima', __DIR__ . '/srcPsr0'); $cachedLoader = new XcacheClassLoader(sha1(__FILE__), $psr0Loader); $cachedLoader->register(); $psr0Loader->unregister(); $psr4Loader = new Psr4ClassLoader(); $psr4Loader->addPrefix('DG\\SymfonyCert\\', __DIR__ . '/src'); $psr4Loader->register(); $mapLoader = new MapClassLoader(['Dima\\Legacy\\TestClass' => __DIR__ . '/srcPsr0/TestClass.php']); $mapLoader->register(); ClassMapGenerator::dump(__DIR__ . '/srcThirdParty', __DIR__ . '/class_map.php'); $classMap = (include __DIR__ . '/class_map.php'); $mapLoader2 = new MapClassLoader($classMap); $mapLoader2->register(); //Psr0 loader + XCache TestPsr0::output("Hello from Psr0 loaded class!");
<?php require_once __DIR__ . '/../../vendor/symfony/class-loader/Symfony/Component/ClassLoader/ClassLoader.php'; use Symfony\Component\ClassLoader\ClassLoader; $loader = new ClassLoader(); $loader->addPrefixes(array('Respect' => __DIR__ . '/../../vendor/respect/validation/library', 'Symfony\\Component\\Validator' => __DIR__ . '/../../vendor/symfony/validator', 'Symfony\\Component\\PropertyAccess' => __DIR__ . '/../../vendor/symfony/property-access', 'Symfony\\Component\\Translation' => __DIR__ . '/../../vendor/symfony/translation', 'HybridLogic' => __DIR__ . '/../../vendor/hybridlogic/validation/src', 'Fuel' => __DIR__ . '/../../vendor/fuelphp/validation/src', 'Zend\\Validator' => __DIR__ . '/../../vendor/zendframework/zend-validator', 'Zend\\Stdlib' => __DIR__ . '/../../vendor/zendframework/zend-stdlib', 'Kpacha\\ComponentBenchmark' => __DIR__ . '/../../src', 'Kpacha\\BenchmarkTool' => __DIR__ . '/../../vendor/kpacha/php-benchmark-tool/src', 'Symfony\\Component\\Finder' => __DIR__ . '/../../vendor/symfony/finder')); $loader->register(); include __DIR__ . '/common.php';
/** * @param ContainerBuilder $container */ private function registerAutoloader(ContainerBuilder $container) { $classLoader = new ClassLoader(); foreach ($container->getParameter('class_loader.prefixes') as $namespace => $path) { $classLoader->addPrefix($namespace, str_replace('%paths.base%', $container->getParameter('paths.base'), $path)); } $classLoader->register(); }
<?php use Symfony\Component\ClassLoader\ClassLoader; require_once __DIR__ . '/../../autoload.php'; function deleteTree($path) { if (!is_dir($path)) { return; } $iterator = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS); foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $subpath) { if ($subpath->isDir()) { rmdir((string) $subpath); } else { unlink((string) $subpath); } } rmdir($path); } // Wipe previously generated proxies deleteTree(__DIR__ . '/../../test/proxies/Doctrine/OrientDB/Proxy/test/Doctrine'); deleteTree(__DIR__ . '/../../test/proxies/Doctrine/OrientDB/Proxy/test/Integration'); // Set up autoloading for testing $loader = new ClassLoader(); $loader->addPrefixes(array('Doctrine\\OrientDB\\Proxy' => __DIR__ . '/../../test/proxies/', 'test' => __DIR__ . '/../../')); $loader->register();
<?php require_once __DIR__ . '/vendor/symfony/class-loader/ClassLoader.php'; use MF\App; use MF\Render\Render; use Symfony\Component\ClassLoader\ClassLoader; $loader = new ClassLoader(); $loader->addPrefix('MF', __DIR__ . '/src_psr0'); $loader->register(); $app = new App(new Render()); $app->renderResponse();
<?php require_once __DIR__ . '/../vendor/symfony/class-loader/ClassLoader.php'; use Symfony\Component\ClassLoader\ClassLoader; $loader = new ClassLoader(); $loader->register(); $loader->addPrefixes(array('DoublesSearchBundle' => __DIR__ . '/../src')); return $loader;
<?php // Work around the lack of proper autoload.php from composer by using // the ClassLoader element from Symfony. // http://symfony.com/doc/current/components/class_loader/class_loader.html require_once 'Symfony/Component/ClassLoader/ClassLoader.php'; use Symfony\Component\ClassLoader\ClassLoader; $loader = new ClassLoader(); $loader->setUseIncludePath(true); $loader->register(); $loader->addPrefixes(array()); // Load additional files as registered in composer require_once 'getid3/getid3.php'; require_once 'libphp-phpmailer/class.phpmailer.php'; require_once 'libphp-phpmailer/class.pop3.php'; require_once 'libphp-phpmailer/class.smtp.php'; require_once 'Assetic/functions.php'; require_once 'Crypt/Random.php';
/** * @dataProvider getLoadClassPrefixCollisionTests */ public function testLoadClassPrefixCollision($prefixes, $className, $message) { $loader = new ClassLoader(); $loader->addPrefixes($prefixes); $loader = new ApcClassLoader('test.prefix.collision.', $loader); $loader->loadClass($className); $this->assertTrue(class_exists($className), $message); }
<?php require_once __DIR__ . '/vendor/symfony/class-loader/ClassLoader.php'; use Symfony\Component\ClassLoader\ClassLoader; use Console\TweetCommand; $loader = new ClassLoader(); $loader->setUseIncludePath(true); $loader->register(); $loader->addPrefix('Console', __DIR__ . '/Console'); $test = new TweetCommand(); echo $test->test();
<?php require_once __DIR__ . '/vendor/symfony/class-loader/ClassLoader.php'; use Symfony\Component\ClassLoader\ClassLoader; use Zs\Model\ClientDigitalLibrary; use Zs\Model\EprintsAdapter; use Zs\Model\Eprints; $loader = new ClassLoader(); $loader->setUseIncludePath(true); $loader->register(); //var_dump($loader); new ClientDigitalLibrary(); //$twitter = new twitterAdapter(new Twitter()); //$twitter->send('Posting to Twitter'); $eprints = new EprintsAdapter(new Eprints()); var_dump($eprints); $eprints->LoadMetadata();
<?php /** * Verone CRM | http://www.veronecrm.com * * @copyright Copyright (C) 2015 - 2016 Adam Banaszkiewicz * @license GNU General Public License version 3; see license.txt */ include_once BASEPATH . '/vendor/autoload.php'; use Symfony\Component\ClassLoader\ClassLoader; $loader = new ClassLoader(); $loader->addPrefix('CRM', BASEPATH . '/core'); $loader->addPrefix('System', BASEPATH . '/core'); $loader->addPrefix('App', BASEPATH . '/app'); $loader->addPrefix('Language', BASEPATH . '/app'); $loader->addPrefix('Helper', BASEPATH . '/app'); $loader->addPrefix('EEHandler', BASEPATH . '/EEHandler'); $loader->register();
<?php require_once $_SERVER['SYMFONY'] . '/Symfony/Component/ClassLoader/ClassLoader.php'; use Symfony\Component\ClassLoader\ClassLoader; $loader = new ClassLoader(); $loader->addPrefix('Symfony', $_SERVER['SYMFONY']); $loader->addPrefix('Thrift', $_SERVER['THRIFT']); $loader->register(); spl_autoload_register(function ($class) { if (0 === strpos($class, 'Overblog\\ThriftBundle\\')) { $path = implode('/', array_slice(explode('\\', $class), 2)) . '.php'; require_once __DIR__ . '/../' . $path; return true; } });
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once __DIR__ . '/../../../../ClassLoader/ClassLoader.php'; use Symfony\Component\ClassLoader\ClassLoader; use Symfony\Component\Finder\Finder; use Symfony\Component\Security\Acl\Dbal\Schema; $loader = new ClassLoader(); $loader->addPrefixes(array('Symfony' => __DIR__ . '/../../../../../..', 'Doctrine\\Common' => __DIR__ . '/../../../../../../../vendor/doctrine-common/lib', 'Doctrine\\DBAL\\Migrations' => __DIR__ . '/../../../../../../../vendor/doctrine-migrations/lib', 'Doctrine\\DBAL' => __DIR__ . '/../../../../../../../vendor/doctrine-dbal/lib', 'Doctrine' => __DIR__ . '/../../../../../../../vendor/doctrine/lib')); $loader->register(); $schema = new Schema(array('class_table_name' => 'acl_classes', 'entry_table_name' => 'acl_entries', 'oid_table_name' => 'acl_object_identities', 'oid_ancestors_table_name' => 'acl_object_identity_ancestors', 'sid_table_name' => 'acl_security_identities')); $reflection = new ReflectionClass('Doctrine\\DBAL\\Platforms\\AbstractPlatform'); $finder = new Finder(); $finder->name('*Platform.php')->in(dirname($reflection->getFileName())); foreach ($finder as $file) { require_once $file->getPathName(); $className = 'Doctrine\\DBAL\\Platforms\\' . $file->getBasename('.php'); $reflection = new ReflectionClass($className); if ($reflection->isAbstract()) { continue; } $platform = $reflection->newInstance(); $targetFile = sprintf(__DIR__ . '/../schema/%s.sql', $platform->name); file_put_contents($targetFile, implode("\n\n", $schema->toSql($platform)));
public function let(ClassLoader $classLoader) { $classLoader->loadClass(Argument::type('string'))->willReturn(false); $this->beConstructedWith($classLoader); }
<?php setlocale(LC_TIME, 'fr_FR.utf8', 'fra'); if (!defined("BASE_ROOT")) { define('BASE_ROOT', dirname(__DIR__)); } require_once BASE_ROOT . '/vendor/autoload.php'; use Symfony\Component\ClassLoader\ClassLoader; $loader = new ClassLoader(); $loader->addPrefix('', array(BASE_ROOT . '/core/class', BASE_ROOT . '/core/class/DoctrineExtension', BASE_ROOT . '/core/helpers', BASE_ROOT . '/core/library/Account', BASE_ROOT . '/core/library/Player', BASE_ROOT . '/core/library/Common', BASE_ROOT . '/core/library/Shared', BASE_ROOT . '/core/library/Site', BASE_ROOT . '/core/library', BASE_ROOT . '/core/twigExtensions')); $loader->register(); \Carbon\Carbon::setLocale('fr');
<?php use Symfony\Component\Debug\Debug; use Symfony\Component\ClassLoader\ClassLoader; // class loader $loader = new ClassLoader(); $loader->addPrefixes(['' => __DIR__ . '/../validators']); $loader->register(); // bootstrap Debug::enable();
/** * {@inheritdoc} */ public function execute(InputInterface $input, OutputInterface $output) { $this->loader->register(); }