/**
  * @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');
     }
 }
 /**
  * {@inheritdoc}
  */
 public function configureContext(ContextInterface $context)
 {
     $context->getResolver()->setDefaults(['debug' => function (Options $options, $value) {
         if (null === $value) {
             $value = $this->kernel->isDebug();
         }
         return $value;
     }])->setAllowedTypes(['debug' => 'bool']);
 }
 /**
  * @return KernelInterface
  */
 private function getKernel(InputInterface $input)
 {
     $env = $input->getParameterOption(['--env', '-e'], $this->baseKernel->getEnvironment());
     $debug = !$input->hasParameterOption(['--no-debug', '']);
     if ($env === $this->baseKernel->getEnvironment() && $debug === $this->baseKernel->isDebug()) {
         return $this->baseKernel;
     }
     $kernelClass = new ReflectionClass($this->baseKernel);
     return $kernelClass->newInstance([$env, $debug]);
 }
 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     $this->data = array('app_name' => $this->name, 'app_version' => $this->version, 'token' => $response->headers->get('X-Debug-Token'), 'symfony_version' => Kernel::VERSION, 'symfony_state' => 'unknown', 'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a', 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 'php_version' => PHP_VERSION, 'xdebug_enabled' => extension_loaded('xdebug'), 'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'), 'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'), 'xcache_enabled' => extension_loaded('xcache') && ini_get('xcache.cacher'), 'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'), 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'), 'bundles' => array(), 'sapi_name' => PHP_SAPI);
     if (isset($this->kernel)) {
         foreach ($this->kernel->getBundles() as $name => $bundle) {
             $this->data['bundles'][$name] = $bundle->getPath();
         }
         $this->data['symfony_state'] = $this->determineSymfonyState();
     }
 }
Beispiel #5
0
 /**
  * Constructor.
  *
  * @param KernelInterface $kernel A KernelInterface instance
  */
 public function __construct(KernelInterface $kernel)
 {
     $this->kernel = $kernel;
     parent::__construct('Symfony', Kernel::VERSION . ' - ' . $kernel->getName() . '/' . $kernel->getEnvironment() . ($kernel->isDebug() ? '/debug' : ''));
     $this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
     $this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
 }
Beispiel #6
0
 /**
  * @param Samples $event
  */
 public function onInstallSamples(SamplesInstall $event)
 {
     // app already installed
     if ($this->installed) {
         return;
     }
     // sample label
     $name = $this->translator->trans('Sample');
     $label = $this->em->getRepository('AnimeDbCatalogBundle:Label')->findOneBy(['name' => $name]);
     $label = $label ?: (new Label())->setName($name);
     $status = false;
     // create items
     foreach ($this->item_chain->getPublicItems() as $item) {
         $status = $this->persist($item, $event->getStorage(), $label) ?: $status;
     }
     // install more items only for debug mode
     if ($this->kernel->isDebug()) {
         foreach ($this->item_chain->getDebugItems() as $item) {
             $status = $this->persist($item, $event->getStorage(), $label) ?: $status;
         }
     }
     if ($status) {
         $this->em->flush();
     }
 }
Beispiel #7
0
 /**
  * Constructor.
  *
  * @param KernelInterface $kernel A KernelInterface instance
  */
 public function __construct(KernelInterface $kernel)
 {
     $this->kernel = $kernel;
     parent::__construct('Symfony', Kernel::VERSION . ' - ' . $kernel->getName() . '/' . $kernel->getEnvironment() . ($kernel->isDebug() ? '/debug' : ''));
     $this->getDefinition()->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, 'Launch the shell.'));
     $this->getDefinition()->addOption(new InputOption('--process-isolation', null, InputOption::VALUE_NONE, 'Launch commands from shell as a separate processes.'));
     $this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
     $this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
 }
Beispiel #8
0
 /**
  * Constructor.
  */
 public function __construct(KernelInterface $kernel)
 {
     $this->kernel = $kernel;
     parent::__construct('Symfony', Kernel::VERSION . ' - ' . $kernel->getName() . '/' . $kernel->getEnvironment() . ($kernel->isDebug() ? '/debug' : ''));
     $this->definition->addOption(new InputOption('--shell', '-s', InputOption::VALUE_NONE, 'Launch the shell.'));
     $this->definition->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', 'dev'));
     $this->definition->addOption(new InputOption('--debug', '-d', InputOption::VALUE_NONE, 'Whether to run in debug mode.'));
     $this->kernel->boot();
     $this->registerCommands();
 }
    /**
     * {@inheritdoc}
     */
    public function collect(Request $request, Response $response, \Exception $exception = null)
    {
        $this->data = array(
            'app_name' => $this->name,
            'app_version' => $this->version,
            'token' => $response->headers->get('X-Debug-Token'),
            'symfony_version' => Kernel::VERSION,
            'symfony_state' => 'unknown',
            'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a',
            'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a',
            'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a',
            'php_version' => PHP_VERSION,
            'php_architecture' => PHP_INT_SIZE * 8,
            'php_intl_locale' => class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a',
            'php_timezone' => date_default_timezone_get(),
            'xdebug_enabled' => extension_loaded('xdebug'),
            'apcu_enabled' => extension_loaded('apcu') && ini_get('apc.enabled'),
            'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'),
            'bundles' => array(),
            'sapi_name' => PHP_SAPI,
        );

        if (isset($this->kernel)) {
            foreach ($this->kernel->getBundles() as $name => $bundle) {
                $this->data['bundles'][$name] = $bundle->getPath();
            }

            $this->data['symfony_state'] = $this->determineSymfonyState();
            $this->data['symfony_minor_version'] = sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION);
            $eom = \DateTime::createFromFormat('m/Y', Kernel::END_OF_MAINTENANCE);
            $eol = \DateTime::createFromFormat('m/Y', Kernel::END_OF_LIFE);
            $this->data['symfony_eom'] = $eom->format('F Y');
            $this->data['symfony_eol'] = $eol->format('F Y');
        }

        if (preg_match('~^(\d+(?:\.\d+)*)(.+)?$~', $this->data['php_version'], $matches) && isset($matches[2])) {
            $this->data['php_version'] = $matches[1];
            $this->data['php_version_extra'] = $matches[2];
        }
    }
Beispiel #10
0
 /**
  * Constructor.
  *
  * @param KernelInterface  $kernel           A KernelInterface instance
  * @param EmbeddedComposer $embeddedComposer Composer Class Loader
  */
 public function __construct(KernelInterface $kernel, EmbeddedComposer $embeddedComposer)
 {
     $this->kernel = $kernel;
     $this->embeddedComposer = $embeddedComposer;
     if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
         date_default_timezone_set(@date_default_timezone_get());
     }
     $version = $embeddedComposer->findPackage('sculpin/sculpin')->getPrettyVersion();
     if ($version !== Sculpin::GIT_VERSION && Sculpin::GIT_VERSION !== '@' . 'git_version' . '@') {
         $version .= ' (' . Sculpin::GIT_VERSION . ')';
     }
     parent::__construct('Sculpin', $version . ' - ' . $kernel->getName() . '/' . $kernel->getEnvironment() . ($kernel->isDebug() ? '/debug' : ''));
     $this->getDefinition()->addOption(new InputOption('--project-dir', null, InputOption::VALUE_REQUIRED, 'The project directory.', '.'));
     $this->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', $kernel->getEnvironment()));
     $this->getDefinition()->addOption(new InputOption('--no-debug', null, InputOption::VALUE_NONE, 'Switches off debug mode.'));
     $this->getDefinition()->addOption(new InputOption('--safe', null, InputOption::VALUE_NONE, 'Enable safe mode (no bundles loaded, no kernel booted)'));
     $this->getDefinition()->addOption(new InputOption('--git-version', null, InputOption::VALUE_NONE, 'See Git version'));
 }
    /**
     * @param KernelInterface $parent
     * @param string          $namespace
     * @param string          $parentClass
     * @param string          $warmupDir
     *
     * @return KernelInterface
     */
    protected function getTempKernel(KernelInterface $parent, $namespace, $parentClass, $warmupDir)
    {
        $rootDir = $parent->getRootDir();
        // the temp kernel class name must have the same length than the real one
        // to avoid the many problems in serialized resources files
        $class = substr($parentClass, 0, -1) . '_';
        // the temp kernel name must be changed too
        $name = substr($parent->getName(), 0, -1) . '_';
        $code = <<<EOF
<?php

namespace {$namespace}
{
    class {$class} extends {$parentClass}
    {
        public function getCacheDir()
        {
            return '{$warmupDir}';
        }

        public function getName()
        {
            return '{$name}';
        }

        public function getRootDir()
        {
            return '{$rootDir}';
        }
    }
}
EOF;
        $this->getContainer()->get('filesystem')->mkdir($warmupDir);
        file_put_contents($file = $warmupDir . '/kernel.tmp', $code);
        require_once $file;
        @unlink($file);
        $class = "{$namespace}\\{$class}";
        return new $class($parent->getEnvironment(), $parent->isDebug());
    }
    /**
     * @param KernelInterface $parent
     * @param string          $namespace
     * @param string          $parentClass
     * @param string          $warmupDir
     *
     * @return KernelInterface
     */
    protected function getTempKernel(KernelInterface $parent, $namespace, $parentClass, $warmupDir)
    {
        $cacheDir = var_export($warmupDir, true);
        $rootDir = var_export(realpath($parent->getRootDir()), true);
        $logDir = var_export(realpath($parent->getLogDir()), true);
        // the temp kernel class name must have the same length than the real one
        // to avoid the many problems in serialized resources files
        $class = substr($parentClass, 0, -1) . '_';
        // the temp kernel name must be changed too
        $name = var_export(substr($parent->getName(), 0, -1) . '_', true);
        $code = <<<EOF
<?php

namespace {$namespace}
{
    class {$class} extends {$parentClass}
    {
        public function getCacheDir()
        {
            return {$cacheDir};
        }

        public function getName()
        {
            return {$name};
        }

        public function getRootDir()
        {
            return {$rootDir};
        }

        public function getLogDir()
        {
            return {$logDir};
        }

        protected function buildContainer()
        {
            \$container = parent::buildContainer();

            // filter container's resources, removing reference to temp kernel file
            \$resources = \$container->getResources();
            \$filteredResources = array();
            foreach (\$resources as \$resource) {
                if ((string) \$resource !== __FILE__) {
                    \$filteredResources[] = \$resource;
                }
            }

            \$container->setResources(\$filteredResources);

            return \$container;
        }
    }
}
EOF;
        $this->getContainer()->get('filesystem')->mkdir($warmupDir);
        file_put_contents($file = $warmupDir . '/kernel.tmp', $code);
        require_once $file;
        $class = "{$namespace}\\{$class}";
        return new $class($parent->getEnvironment(), $parent->isDebug());
    }
    protected function getTempKernel(KernelInterface $parent, $namespace, $class, $warmupDir)
    {
        $suffix = $this->getTempKernelSuffix();
        $rootDir = $parent->getRootDir();
        $code = <<<EOF
<?php

namespace {$namespace}
{
    class {$class}{$suffix} extends {$class}
    {
        public function getCacheDir()
        {
            return '{$warmupDir}';
        }

        public function getRootDir()
        {
            return '{$rootDir}';
        }

        protected function getContainerClass()
        {
            return parent::getContainerClass().'{$suffix}';
        }
    }
}
EOF;
        $this->getContainer()->get('filesystem')->mkdir($warmupDir);
        file_put_contents($file = $warmupDir . '/kernel.tmp', $code);
        require_once $file;
        @unlink($file);
        $class = "{$namespace}\\{$class}{$suffix}";
        return new $class($parent->getEnvironment(), $parent->isDebug());
    }
 /**
  * @param KernelInterface $kernel
  */
 public function __construct(KernelInterface $kernel)
 {
     $this->kernel = $kernel;
     $cacheScriptPath = $this->kernel->getCacheDir() . self::CACHE_SCRIPT_PATH;
     $this->configCache = new ConfigCache($cacheScriptPath, $this->kernel->isDebug());
 }
Beispiel #15
0
 /**
  * {@inheritdoc}
  */
 public function isDebug()
 {
     return $this->kernel->isDebug();
 }