Created
October 29, 2015 18:20
-
-
Save weaverryan/3a3f879c65ab7785114c to your computer and use it in GitHub Desktop.
Potential Symfony MicroKernel example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once __DIR__.'/../vendor/autoload.php'; | |
use Symfony\Component\Config\Loader\LoaderInterface; | |
use Symfony\Component\DependencyInjection\ContainerBuilder; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
use Symfony\Component\HttpKernel\MicroKernel; | |
use Symfony\Component\Routing\RouteCollectionBuilder; | |
class AppKernel extends MicroKernel | |
{ | |
public function home() | |
{ | |
return new Response('Foo'); | |
} | |
public function registerBundles() | |
{ | |
return array( | |
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), | |
); | |
} | |
protected function configureRoutes(RouteCollectionBuilder $routes) | |
{ | |
$routes->add('/', 'kernel:home'); | |
} | |
protected function configureServices(ContainerBuilder $c, LoaderInterface $loader) | |
{ | |
$c->setParameter('kernel.secret', 'foo'); | |
} | |
} | |
$kernel = new AppKernel('dev', true); | |
$request = Request::createFromGlobals(); | |
$response = $kernel->handle($request); | |
$response->send(); | |
$kernel->terminate($request, $response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment