本文整理汇总了PHP中Symfony\Component\ClassLoader\ClassCollectionLoader::load方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassCollectionLoader::load方法的具体用法?PHP ClassCollectionLoader::load怎么用?PHP ClassCollectionLoader::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\ClassLoader\ClassCollectionLoader
的用法示例。
在下文中一共展示了ClassCollectionLoader::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: warmUp
/**
* @param string $cacheDir
*/
public function warmUp($cacheDir)
{
$mapFile = $cacheDir . '/classes.map';
if (is_file($mapFile)) {
ClassCollectionLoader::load(include $mapFile, $cacheDir, 'classes', $this->kernel->isDebug(), false, '.php');
}
}
示例2: createClassCache
protected function createClassCache($cacheDir, $debug)
{
$classmap = $cacheDir . '/classes.map';
if (is_file($classmap)) {
ClassCollectionLoader::load(include $classmap, $cacheDir, 'classes', $debug, false, '.php');
}
}
示例3: warmUp
/**
* Warms up the cache.
*
* @param string $cacheDir The cache directory
*/
public function warmUp($cacheDir)
{
$classmap = $cacheDir . '/classes.map';
if (!is_file($classmap)) {
return;
}
ClassCollectionLoader::load(include $classmap, $cacheDir, 'classes', false);
}
示例4: doBuildBootstrap
public static function doBuildBootstrap($appDir)
{
$file = $appDir . '/bootstrap.php.cache';
if (file_exists($file)) {
unlink($file);
}
ClassCollectionLoader::load(array('Symfony\\Component\\DependencyInjection\\ContainerAwareInterface', 'Symfony\\Component\\DependencyInjection\\Container', 'Symfony\\Component\\HttpKernel\\Kernel', 'Symfony\\Component\\ClassLoader\\ClassCollectionLoader', 'Symfony\\Component\\ClassLoader\\ApcClassLoader', 'Symfony\\Component\\HttpKernel\\Bundle\\Bundle', 'Symfony\\Component\\Config\\ConfigCache', 'Symfony\\Bundle\\FrameworkBundle\\HttpKernel'), dirname($file), basename($file, '.php.cache'), false, false, '.php.cache');
file_put_contents($file, sprintf("<?php\n\nnamespace { \$loader = require_once __DIR__.'/autoload.php'; }\n\n%s\n\nnamespace { return \$loader; }\n ", substr(file_get_contents($file), 5)));
}
示例5: execute
/**
* {@inheritDoc}
*/
public function execute(InputInterface $input, OutputInterface $output)
{
$kernel = $this->getContainer()->get('kernel');
$classmap = $kernel->getCacheDir() . '/classes.map';
if (!is_file($classmap)) {
throw new \RuntimeException(sprintf('The file %s does not exist', $classmap));
}
$name = 'classes';
$extension = '.php';
$output->write("<info>Writing cache file ...</info>");
ClassCollectionLoader::load(include $classmap, $kernel->getCacheDir(), $name, $kernel->isDebug(), false, $extension);
$output->writeln(" done!");
}
示例6: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$kernel = $this->getContainer()->get('kernel');
$output->writeln(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
$warmer = $this->getContainer()->get('cache_warmer');
if (!$input->getOption('no-optional-warmers')) {
$warmer->enableOptionalWarmers();
}
$cacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
$warmer->warmUp($cacheDir);
$classmap = $cacheDir . '/classes.map';
if (is_file($classmap)) {
ClassCollectionLoader::load(include $classmap, $cacheDir, 'classes', $kernel->isDebug(), false, '.php');
}
}
示例7: boot
/**
* Boots the Bundle.
*/
public function boot()
{
// load core classes
ClassCollectionLoader::load($this->container->getParameter('kernel.compiled_classes'), $this->container->getParameter('kernel.cache_dir'), 'classes', $this->container->getParameter('kernel.debug'), true);
if ($this->container->has('error_handler')) {
$this->container->get('error_handler');
}
if ($this->container->hasParameter('document_root')) {
File::setDocumentRoot($this->container->getParameter('document_root'));
}
if (file_exists($this->container->getParameter('kernel.cache_dir') . '/autoload.php')) {
$classloader = new MapFileClassLoader($this->container->getParameter('kernel.cache_dir') . '/autoload.php');
$classloader->register(true);
}
}
示例8: exit
* file that was distributed with this source code.
*/
$argv = $_SERVER['argv'];
// allow the base path to be passed as the first argument, or default
if (isset($argv[1])) {
$baseDir = $argv[1];
} else {
if (!($baseDir = realpath(__DIR__ . '/..'))) {
exit('Looks like you don\'t have a standard layout.');
}
}
require_once $baseDir . '/vendor/symfony/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Symfony\Component\ClassLoader\UniversalClassLoader;
use Symfony\Component\ClassLoader\ClassCollectionLoader;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array('Symfony' => $baseDir . '/vendor/symfony/symfony/src'));
$loader->register();
$file = $baseDir . '/app/bootstrap.php.cache';
if (file_exists($file)) {
unlink($file);
}
ClassCollectionLoader::load(array('Symfony\\Component\\DependencyInjection\\ContainerAwareInterface', 'Symfony\\Component\\DependencyInjection\\ContainerInterface', 'Symfony\\Component\\DependencyInjection\\Container', 'Symfony\\Component\\HttpKernel\\HttpKernelInterface', 'Symfony\\Component\\HttpKernel\\KernelInterface', 'Symfony\\Component\\HttpKernel\\Kernel', 'Symfony\\Component\\ClassLoader\\ClassCollectionLoader', 'Symfony\\Component\\ClassLoader\\UniversalClassLoader', 'Symfony\\Component\\HttpKernel\\Bundle\\Bundle', 'Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface', 'Symfony\\Component\\Config\\ConfigCache'), dirname($file), basename($file, '.php.cache'), false, false, '.php.cache');
file_put_contents($file, "<?php\n\nnamespace { require_once __DIR__.'/autoload.php'; }\n\n" . substr(file_get_contents($file), 5));
示例9: array
#!/usr/bin/env php
<?php
// Compiles EmailMakr into one big PHP file
// Ported from Sismo https://github.com/fabpot/Sismo
use Symfony\Component\ClassLoader\ClassCollectionLoader;
require_once __DIR__ . '/vendor/autoload.php';
@mkdir(__DIR__ . '/build', 0777, true);
@unlink(__DIR__ . '/build/emailmakr.php');
$classes = array('Pimple', 'Sensio\\Command\\Build', 'Symfony\\Component\\Console\\Application', 'Symfony\\Component\\Console\\Command\\Command', 'Symfony\\Component\\Console\\Command\\HelpCommand', 'Symfony\\Component\\Console\\Command\\ListCommand', 'Symfony\\Component\\Console\\Descriptor\\ApplicationDescription', 'Symfony\\Component\\Console\\Descriptor\\JsonDescriptor', 'Symfony\\Component\\Console\\Descriptor\\MarkdownDescriptor', 'Symfony\\Component\\Console\\Descriptor\\TextDescriptor', 'Symfony\\Component\\Console\\Descriptor\\XmlDescriptor', 'Symfony\\Component\\Console\\Formatter\\OutputFormatter', 'Symfony\\Component\\Console\\Formatter\\OutputFormatterStyle', 'Symfony\\Component\\Console\\Formatter\\OutputFormatterStyleStack', 'Symfony\\Component\\Console\\Helper\\DescriptorHelper', 'Symfony\\Component\\Console\\Helper\\DialogHelper', 'Symfony\\Component\\Console\\Helper\\FormatterHelper', 'Symfony\\Component\\Console\\Helper\\Helper', 'Symfony\\Component\\Console\\Helper\\HelperSet', 'Symfony\\Component\\Console\\Helper\\ProgressHelper', 'Symfony\\Component\\Console\\Helper\\TableHelper', 'Symfony\\Component\\Console\\Input\\ArgvInput', 'Symfony\\Component\\Console\\Input\\ArrayInput', 'Symfony\\Component\\Console\\Input\\Input', 'Symfony\\Component\\Console\\Input\\InputArgument', 'Symfony\\Component\\Console\\Input\\InputDefinition', 'Symfony\\Component\\Console\\Input\\InputOption', 'Symfony\\Component\\Console\\Input\\StringInput', 'Symfony\\Component\\Console\\Output\\ConsoleOutput', 'Symfony\\Component\\Console\\Output\\NullOutput', 'Symfony\\Component\\Console\\Output\\Output', 'Symfony\\Component\\Console\\Output\\StreamOutput', 'Symfony\\Component\\Console\\Shell', 'Twig_Autoloader', 'Twig_Compiler', 'Twig_Environment', 'Twig_Error', 'Twig_Error_Loader', 'Twig_Error_Runtime', 'Twig_Error_Syntax', 'Twig_ExpressionParser', 'Twig_Extension_Core', 'Twig_Extension_Debug', 'Twig_Extension_Escaper', 'Twig_Extension_Optimizer', 'Twig_Extension_Sandbox', 'Twig_Extension_Staging', 'Twig_Filter_Function', 'Twig_Filter_Method', 'Twig_Filter_Node', 'Twig_Function_Function', 'Twig_Function_Method', 'Twig_Function_Node', 'Twig_Lexer', 'Twig_Loader_Array', 'Twig_Loader_Chain', 'Twig_Loader_Filesystem', 'Twig_Loader_String', 'Twig_Markup', 'Twig_Node', 'Twig_Node_AutoEscape', 'Twig_Node_Block', 'Twig_Node_BlockReference', 'Twig_Node_Body', 'Twig_Node_Do', 'Twig_Node_Embed', 'Twig_Node_Expression_Array', 'Twig_Node_Expression_AssignName', 'Twig_Node_Expression_Binary_Add', 'Twig_Node_Expression_Binary_And', 'Twig_Node_Expression_Binary_BitwiseAnd', 'Twig_Node_Expression_Binary_BitwiseOr', 'Twig_Node_Expression_Binary_BitwiseXor', 'Twig_Node_Expression_Binary_Concat', 'Twig_Node_Expression_Binary_Div', 'Twig_Node_Expression_Binary_Equal', 'Twig_Node_Expression_Binary_FloorDiv', 'Twig_Node_Expression_Binary_Greater', 'Twig_Node_Expression_Binary_GreaterEqual', 'Twig_Node_Expression_Binary_In', 'Twig_Node_Expression_Binary_Less', 'Twig_Node_Expression_Binary_LessEqual', 'Twig_Node_Expression_Binary_Mod', 'Twig_Node_Expression_Binary_Mul', 'Twig_Node_Expression_Binary_NotEqual', 'Twig_Node_Expression_Binary_NotIn', 'Twig_Node_Expression_Binary_Or', 'Twig_Node_Expression_Binary_Power', 'Twig_Node_Expression_Binary_Range', 'Twig_Node_Expression_Binary_Sub', 'Twig_Node_Expression_BlockReference', 'Twig_Node_Expression_Conditional', 'Twig_Node_Expression_Constant', 'Twig_Node_Expression_ExtensionReference', 'Twig_Node_Expression_Filter', 'Twig_Node_Expression_Filter_Default', 'Twig_Node_Expression_Function', 'Twig_Node_Expression_GetAttr', 'Twig_Node_Expression_MethodCall', 'Twig_Node_Expression_Name', 'Twig_Node_Expression_Parent', 'Twig_Node_Expression_TempName', 'Twig_Node_Expression_Test', 'Twig_Node_Expression_Test_Constant', 'Twig_Node_Expression_Test_Defined', 'Twig_Node_Expression_Test_Divisibleby', 'Twig_Node_Expression_Test_Even', 'Twig_Node_Expression_Test_Null', 'Twig_Node_Expression_Test_Odd', 'Twig_Node_Expression_Test_Sameas', 'Twig_Node_Expression_Unary_Neg', 'Twig_Node_Expression_Unary_Not', 'Twig_Node_Expression_Unary_Pos', 'Twig_Node_Flush', 'Twig_Node_For', 'Twig_Node_ForLoop', 'Twig_Node_If', 'Twig_Node_Import', 'Twig_Node_Include', 'Twig_Node_Macro', 'Twig_Node_Module', 'Twig_Node_Print', 'Twig_Node_Sandbox', 'Twig_Node_SandboxedModule', 'Twig_Node_SandboxedPrint', 'Twig_Node_Set', 'Twig_Node_SetTemp', 'Twig_Node_Spaceless', 'Twig_Node_Text', 'Twig_NodeTraverser', 'Twig_NodeVisitor_Escaper', 'Twig_NodeVisitor_Optimizer', 'Twig_NodeVisitor_SafeAnalysis', 'Twig_NodeVisitor_Sandbox', 'Twig_Parser', 'Twig_Sandbox_SecurityError', 'Twig_Sandbox_SecurityPolicy', 'Twig_SimpleFilter', 'Twig_SimpleFunction', 'Twig_SimpleTest', 'Twig_Template', 'Twig_Token', 'Twig_TokenParser_AutoEscape', 'Twig_TokenParser_Block', 'Twig_TokenParser_Do', 'Twig_TokenParser_Embed', 'Twig_TokenParser_Extends', 'Twig_TokenParser_Filter', 'Twig_TokenParser_Flush', 'Twig_TokenParser_For', 'Twig_TokenParser_From', 'Twig_TokenParser_If', 'Twig_TokenParser_Import', 'Twig_TokenParser_Include', 'Twig_TokenParser_Macro', 'Twig_TokenParser_Sandbox', 'Twig_TokenParser_Set', 'Twig_TokenParser_Spaceless', 'Twig_TokenParser_Use', 'Twig_TokenParserBroker', 'Twig_TokenStream');
$ccl = new ClassCollectionLoader();
$ccl->load($classes, __DIR__ . '/build', 'emailmakr', false);
$classes = str_replace('<?php', '', file_get_contents(__DIR__ . '/build/emailmakr.php'));
$classes = str_replace("eval('?>'.", 'eval(', $classes);
$app = 'namespace {' . str_replace('<?php', '', file_get_contents(__DIR__ . '/emailmakr')) . '}';
$app = str_replace('#!/usr/bin/env php', '', $app);
$license = file_get_contents(__DIR__ . '/LICENSE');
$content = "#!/usr/bin/env php\n<?php\n\n/*\n{$license}\n*/\n{$classes}\n{$app}\n";
// remove require_once calls
$content = preg_replace('#require_once[^;]+?;#', '', $content);
file_put_contents(__DIR__ . '/build/emailmakr.php', $content);
@chmod(__DIR__ . '/build/emailmakr.php', 0755);
示例10: doBuildBootstrap
public static function doBuildBootstrap($appDir)
{
$file = $appDir . '/bootstrap.php.cache';
if (file_exists($file)) {
unlink($file);
}
$classes = array('Symfony\\Component\\HttpFoundation\\ParameterBag', 'Symfony\\Component\\HttpFoundation\\HeaderBag', 'Symfony\\Component\\HttpFoundation\\FileBag', 'Symfony\\Component\\HttpFoundation\\ServerBag', 'Symfony\\Component\\HttpFoundation\\Request', 'Symfony\\Component\\HttpFoundation\\Response', 'Symfony\\Component\\HttpFoundation\\ResponseHeaderBag', 'Symfony\\Component\\DependencyInjection\\ContainerAwareInterface', 'Symfony\\Component\\DependencyInjection\\Container', 'Symfony\\Component\\HttpKernel\\Kernel', 'Symfony\\Component\\ClassLoader\\ClassCollectionLoader', 'Symfony\\Component\\ClassLoader\\ApcClassLoader', 'Symfony\\Component\\HttpKernel\\Bundle\\Bundle', 'Symfony\\Component\\Config\\ConfigCache');
// introspect the autoloader to get the right file
// we cannot use class_exist() here as it would load the class
// which won't be included into the cache then.
// we know that composer autoloader is first (see bin/build_bootstrap.php)
$autoloaders = spl_autoload_functions();
if ($autoloaders[0][0]->findFile('Symfony\\Bundle\\FrameworkBundle\\HttpKernel')) {
$classes[] = 'Symfony\\Bundle\\FrameworkBundle\\HttpKernel';
} else {
$classes[] = 'Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel';
}
ClassCollectionLoader::load($classes, dirname($file), basename($file, '.php.cache'), false, false, '.php.cache');
file_put_contents($file, sprintf("<?php\n\nnamespace { \$loader = require_once __DIR__.'/autoload.php'; }\n\n%s\n\nnamespace { return \$loader; }\n ", substr(file_get_contents($file), 5)));
}
示例11: doBuildBootstrap
public static function doBuildBootstrap($bootstrapDir, $autoloadDir = null, $useNewDirectoryStructure = false)
{
$file = $bootstrapDir . '/bootstrap.php.cache';
if (file_exists($file)) {
unlink($file);
}
$classes = array('Symfony\\Component\\HttpFoundation\\ParameterBag', 'Symfony\\Component\\HttpFoundation\\HeaderBag', 'Symfony\\Component\\HttpFoundation\\FileBag', 'Symfony\\Component\\HttpFoundation\\ServerBag', 'Symfony\\Component\\HttpFoundation\\Request', 'Symfony\\Component\\HttpFoundation\\Response', 'Symfony\\Component\\HttpFoundation\\ResponseHeaderBag', 'Symfony\\Component\\DependencyInjection\\ContainerAwareInterface', 'Symfony\\Component\\DependencyInjection\\Container', 'Symfony\\Component\\HttpKernel\\Kernel', 'Symfony\\Component\\ClassLoader\\ClassCollectionLoader', 'Symfony\\Component\\ClassLoader\\ApcClassLoader', 'Symfony\\Component\\HttpKernel\\Bundle\\Bundle', 'Symfony\\Component\\Config\\ConfigCache');
// introspect the autoloader to get the right file
// we cannot use class_exist() here as it would load the class
// which won't be included into the cache then.
// we know that composer autoloader is first (see bin/build_bootstrap.php)
$autoloaders = spl_autoload_functions();
if (is_array($autoloaders[0]) && method_exists($autoloaders[0][0], 'findFile') && $autoloaders[0][0]->findFile('Symfony\\Bundle\\FrameworkBundle\\HttpKernel')) {
$classes[] = 'Symfony\\Bundle\\FrameworkBundle\\HttpKernel';
} else {
$classes[] = 'Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel';
}
ClassCollectionLoader::load($classes, dirname($file), basename($file, '.php.cache'), false, false, '.php.cache');
$fs = new Filesystem();
$bootstrapContent = substr(file_get_contents($file), 5);
if ($useNewDirectoryStructure) {
$cacheDir = $fs->makePathRelative($bootstrapDir, $autoloadDir);
$bootstrapContent = str_replace(array("return \$this->rootDir.'/logs", "return \$this->rootDir.'/cache"), array("return \$this->rootDir.'/" . $cacheDir . "logs", "return \$this->rootDir.'/" . $cacheDir . "cache"), $bootstrapContent);
}
if ($autoloadDir) {
$fs = new Filesystem();
$autoloadDir = $fs->makePathRelative($autoloadDir, $bootstrapDir);
}
file_put_contents($file, sprintf(<<<'EOF'
<?php
namespace {
error_reporting(error_reporting() & ~E_USER_DEPRECATED);
$loader = require_once __DIR__.'/%sautoload.php';
}
%s
namespace { return $loader; }
EOF
, $autoloadDir, $bootstrapContent));
}
示例12: writeCache
public function writeCache($file)
{
ClassCollectionLoader::load($this->getClassList(), dirname($file), basename($file, '.php.cache'), false, false, '.php.cache');
$bootstrapContent = substr(file_get_contents($file), $this->phpHeaderOpenTagLength);
file_put_contents($file, sprintf("<?php\n%s", $bootstrapContent));
}
示例13: testCommentStripping
public function testCommentStripping()
{
if (is_file($file = sys_get_temp_dir() . '/bar.php')) {
unlink($file);
}
spl_autoload_register($r = function ($class) {
if (0 === strpos($class, 'Namespaced') || 0 === strpos($class, 'Pearlike_')) {
require_once __DIR__ . '/Fixtures/' . str_replace(array('\\', '_'), '/', $class) . '.php';
}
});
ClassCollectionLoader::load(array('Namespaced\\WithComments', 'Pearlike_WithComments'), sys_get_temp_dir(), 'bar', false);
spl_autoload_unregister($r);
$this->assertEquals(<<<EOF
namespace Namespaced
{
class WithComments
{
public static \$loaded = true;
}
\$string ='string shoult not be modified {\$string}';
\$heredoc = (<<<HD
Heredoc should not be modified {\$string}
HD
);
\$nowdoc =<<<'ND'
Nowdoc should not be modified {\$string}
ND
;
}
namespace
{
class Pearlike_WithComments
{
public static \$loaded = true;
}
}
EOF
, str_replace("<?php \n", '', file_get_contents($file)));
unlink($file);
}
示例14: doBuildBootstrap
public static function doBuildBootstrap($appDir)
{
$file = $appDir.'/bootstrap.php.cache';
if (file_exists($file)) {
unlink($file);
}
$classes = array(
'Symfony\\Component\\DependencyInjection\\ContainerAwareInterface',
// Cannot be included because annotations will parse the big compiled class file
//'Symfony\\Component\\DependencyInjection\\ContainerAware',
'Symfony\\Component\\DependencyInjection\\Container',
'Symfony\\Component\\HttpKernel\\Kernel',
'Symfony\\Component\\ClassLoader\\ClassCollectionLoader',
'Symfony\\Component\\ClassLoader\\ApcClassLoader',
'Symfony\\Component\\HttpKernel\\Bundle\\Bundle',
'Symfony\\Component\\Config\\ConfigCache',
// cannot be included as commands are discovered based on the path to this class via Reflection
//'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle',
);
// introspect the autoloader to get the right file
// we cannot use class_exist() here as it would load the class
// which won't be included into the cache then.
// we know that composer autoloader is first (see bin/build_bootstrap.php)
$autoloaders = spl_autoload_functions();
if ($autoloaders[0][0]->findFile('Symfony\\Bundle\\FrameworkBundle\\HttpKernel')) {
$classes[] = 'Symfony\\Bundle\\FrameworkBundle\\HttpKernel';
} else {
$classes[] = 'Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel';
}
ClassCollectionLoader::load($classes, dirname($file), basename($file, '.php.cache'), false, false, '.php.cache');
file_put_contents($file, sprintf("<?php
namespace { \$loader = require_once __DIR__.'/autoload.php'; }
%s
namespace { return \$loader; }
", substr(file_get_contents($file), 5)));
}
示例15: testUnableToLoadClassException
/**
* @expectedException InvalidArgumentException
*/
public function testUnableToLoadClassException()
{
ClassCollectionLoader::load(array('SomeNotExistingClass'), '', 'foo', false);
}