本文整理汇总了PHP中Symfony\Component\ClassLoader\ClassCollectionLoader类的典型用法代码示例。如果您正苦于以下问题:PHP ClassCollectionLoader类的具体用法?PHP ClassCollectionLoader怎么用?PHP ClassCollectionLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ClassCollectionLoader类的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: warmUp
/**
* Warms up the cache.
*
* @param string $cacheDir The cache directory
*/
public function warmUp($cacheDir)
{
$classmap = $cacheDir . '/classes.map';
if (!is_file($classmap)) {
return;
}
if (file_exists($cacheDir . '/classes.php')) {
return;
}
$declared = null !== $this->declaredClasses ? $this->declaredClasses : array_merge(get_declared_classes(), get_declared_interfaces(), get_declared_traits());
ClassCollectionLoader::inline(include $classmap, $cacheDir . '/classes.php', $declared);
}
示例6: 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!");
}
示例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: 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');
}
}
示例9: testFixNamespaceDeclarations
public function testFixNamespaceDeclarations()
{
$source = <<<EOF
<?php
namespace Foo;
class Foo {}
namespace Bar ;
class Foo {}
namespace Foo\\Bar;
class Foo {}
namespace Foo\\Bar\\Bar
{
class Foo {}
}
namespace
{
class Foo {}
}
EOF;
$expected = <<<EOF
<?php
namespace Foo
{
class Foo {}
}
namespace Bar
{
class Foo {}
}
namespace Foo\\Bar
{
class Foo {}
}
namespace Foo\\Bar\\Bar
{
class Foo {}
}
namespace
{
class Foo {}
}
EOF;
$this->assertEquals($expected, ClassCollectionLoader::fixNamespaceDeclarations($source));
}
示例10: 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));
示例11: 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);
示例12: 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)));
}
示例13: getenv
#!/usr/bin/env php
<?php
// Compiles the SDK and required Libs into one PHP file.
use Symfony\Component\ClassLoader\ClassCollectionLoader;
use Symfony\Component\Finder\Finder;
require_once __DIR__ . '/../vendor/autoload.php';
// Ensure the build directory is writtable and that any previous
// compiles are deleted.
@mkdir(__DIR__ . '/../build', 0777, true);
@unlink(__DIR__ . '/../build/recensus.php');
$withDeps = getenv('COMPILE_DEPS');
if ($withDeps) {
$classes = array('Zend_Exception', 'Zend_Registry', 'Zend_Uri', 'Zend_Uri_Exception', 'Zend_Http_Client', 'Zend_Http_Exception', 'Zend_Http_Response', 'Zend_Http_Client_Exception', 'Zend_Http_Client_Adapter_Curl', 'Zend_Http_Client_Adapter_Exception', 'Zend_Http_Client_Adapter_Interface', 'Zend_Http_Client_Adapter_Proxy', 'Zend_Http_Client_Adapter_Socket', 'Zend_Http_Client_Adapter_Stream', 'Zend_Http_Client_Adapter_Test', 'Zend_Http_Response_Stream', 'Zend_Uri_Http', 'Zend_Validate_Abstract', 'Zend_Validate_Exception', 'Zend_Validate_Hostname', 'Zend_Validate_Interface', 'Zend_Validate_Ip', 'Zend_Loader', 'Zend_Loader_Autoloader', 'Zend_Validate_Hostname_Biz', 'Zend_Validate_Hostname_Cn', 'Zend_Validate_Hostname_Com', 'Zend_Validate_Hostname_Jp');
} else {
$classes = array();
}
$classesToCompile = array_merge($classes, array("Recensus_Api", "Recensus_Api_Exception", "Recensus_Widget", "Recensus_Widget_Exception"));
$ccl = new ClassCollectionLoader();
$ccl->load($classesToCompile, __DIR__ . '/../build', 'recensus', false);
$debug = getenv('COMPILE_DEBUG');
if (!$debug) {
file_put_contents(__DIR__ . '/../build/recensus.php', "<?php " . str_replace('<?php', '', php_strip_whitespace(__DIR__ . '/../build/recensus.php')));
}
示例14: 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));
}
示例15: 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);
}