Skip to content

Instantly share code, notes, and snippets.

@weaverryan
Last active October 5, 2015 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weaverryan/25351e929a5a0d04c1e6 to your computer and use it in GitHub Desktop.
Save weaverryan/25351e929a5a0d04c1e6 to your computer and use it in GitHub Desktop.
AppKernel with new loading
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
protected function configureServices(ContainerBuilder $c, LoaderInterface $loader)
{
$loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml');
}
protected function configureRoutes(RouteCollectionBuilder $routes)
{
// (this would remove routing_dev.yml)
if (isset($this->bundles['WebProfilerBundle'])) {
$routes->import(
'@WebProfilerBundle/Resources/config/routing/wdt.xml',
'/_wdt'
);
$routes->import(
'@WebProfilerBundle/Resources/config/routing/profiler.xml',
'_profile'
);
}
$routes->import(__DIR__.'/config/routing.yml');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment