Skip to content

Instantly share code, notes, and snippets.

@kabdessamad1
Created March 24, 2017 19:57
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 kabdessamad1/8345c938de56728471be44e8380507eb to your computer and use it in GitHub Desktop.
Save kabdessamad1/8345c938de56728471be44e8380507eb to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
];
if($this->getEnvironment() == 'dev') {
$bundles[] = new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
}
return $bundles;
}
public function registerContainerConfiguration(LoaderInterface $loader)
{
$loader->load(__DIR__.'/config/config.yml');
$isDevEnv = $this->getEnvironment() == 'dev';
$loader->load(function (ContainerBuilder $container) use($isDevEnv) {
if($isDevEnv) {
$container->loadFromExtension('web_profiler', [
'toolbar' => true,
]);
}
if ($isDevEnv) {
$container->loadFromExtension('framework', array(
'router' => array(
'resource' => '%kernel.root_dir%/config/routing_dev.yml',
)
));
}
});
}
}
framework:
secret: AJSZDLW)992372
router:
resource: '%kernel.root_dir%/config/routing.yml'
templating:
engines: [twig]
profiler:
enabled: "%kernel.debug%"
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
umask(0000);
$loader = require_once __DIR__.'/../config/autoload.php';
$dotenv = new \Dotenv\Dotenv(__DIR__.'/../');
$dotenv->load();
$env = $_SERVER['SYMFONY_ENV'];
$debug = $_SERVER['SYMFONY_DEBUG'];
if ($debug) {
Debug::enable();
}
require_once __DIR__.'/../AppKernel.php';
$kernel = new AppKernel($env, $debug);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
app_annotations:
resource: '@AppBundle/Controller'
type: annotation
_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt
_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler
_main:
resource: routing.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment