This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/HttpKernel
2012-03-19 00:57:46 +01:00
..
Bundle Changed the wording of the exception thrown when Bundle::getAlias() returns something different to the Container::underscore version, fixes #1768 2011-07-26 20:18:06 +10:00
CacheWarmer [DoctrineBridge] fixed some CS 2011-12-13 10:22:12 +01:00
Config [Phpdoc] Cleaning/fixing 2011-04-23 15:18:47 +00:00
Controller change explode's limit parameter based on known variable content 2011-12-11 21:58:35 +01:00
DataCollector [HttpKernel] tagged public @api 2011-07-20 10:14:31 +02:00
Debug [HttpKernel] fixed error message in HttpKernel 2011-07-22 09:55:31 +02:00
DependencyInjection removed unused use statements 2011-10-29 11:56:30 +02:00
Event removed unused use statements 2011-10-29 11:56:30 +02:00
EventListener removed unused use statements 2011-11-24 07:16:14 +01:00
Exception [HttpKernel] lowered the number of level to keep in Flattened exceptions to make the tests pass when XDebug is enabled (beause of the default max nesting level of 100) 2011-07-16 00:29:33 +02:00
HttpCache Update src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php 2012-03-15 20:27:40 +01:00
Log [DoctrineBridge] fixed some CS 2011-12-13 10:22:12 +01:00
Profiler optimized string starts with checks 2012-01-11 11:33:56 -08:00
Util fixed CS 2011-12-18 14:42:59 +01:00
Client.php [HttpKernel][Client] Only simple (name=value without any other params) cookies can be stored in same line, so lets add every as standalone to be compliant with rfc6265 2011-12-15 11:35:58 +01:00
composer.json removed the version attribute in all composer.json files 2012-01-05 14:51:20 +01:00
HttpKernel.php [HttpKernel] tagged public @api 2011-07-20 10:14:31 +02:00
HttpKernelInterface.php [HttpKernel] tagged public @api 2011-07-20 10:14:31 +02:00
Kernel.php updated VERSION for 2.0.12 2012-03-19 00:57:46 +01:00
KernelEvents.php [HttpKernel] tagged public @api 2011-07-20 10:14:31 +02:00
KernelInterface.php changed the way we store the current ob level (refs #2617) 2011-11-11 23:35:49 +01:00
LICENSE Updated LICENSE files copyright 2012-02-22 10:10:37 +01:00
README.md tweaked the README files 2011-12-18 14:22:28 +01:00

HttpKernel Component

HttpKernel provides the building blocks to create flexible and fast HTTP-based frameworks.

HttpKernelInterface is the core interface of the Symfony2 full-stack framework:

interface HttpKernelInterface
{
    /**
     * Handles a Request to convert it to a Response.
     *
     * @param  Request $request A Request instance
     *
     * @return Response A Response instance
     */
    function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true);
}

It takes a Request as an input and should return a Response as an output. Using this interface makes your code compatible with all frameworks using the Symfony2 components. And this will gives you many cool features for free.

Creating a framework based on the Symfony2 components is really easy. Here is a very simple, but fully-featured framework based on the Symfony2 components:

$routes = new RouteCollection();
$routes->add('hello', new Route('/hello', array('_controller' =>
    function (Request $request) {
        return new Response(sprintf("Hello %s", $request->get('name')));
    }
)));

$request = Request::createFromGlobals();

$context = new RequestContext();
$context->fromRequest($request);

$matcher = new UrlMatcher($routes, $context);

$dispatcher = new EventDispatcher();
$dispatcher->addSubscriber(new RouterListener($matcher));

$resolver = new ControllerResolver();

$kernel = new HttpKernel($dispatcher, $resolver);

$kernel->handle($request)->send();

This is all you need to create a flexible framework with the Symfony2 components.

Want to add an HTTP reverse proxy and benefit from HTTP caching and Edge Side Includes?

$kernel = new HttpKernel($dispatcher, $resolver);

$kernel = new HttpCache($kernel, new Store(__DIR__.'/cache'));

Want to functional test this small framework?

$client = new Client($kernel);
$crawler = $client->request('GET', '/hello/Fabien');

$this->assertEquals('Fabien', $crawler->filter('p > span')->text());

Want nice error pages instead of ugly PHP exceptions?

$dispatcher->addSubscriber(new ExceptionListener(function (Request $request) {
    $msg = 'Something went wrong! ('.$request->get('exception')->getMessage().')';

    return new Response($msg, 500);
}));

And that's why the simple looking HttpKernelInterface is so powerful. It gives you access to a lot of cool features, ready to be used out of the box, with no efforts.

Resources

Unit tests:

https://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Component/HttpKernel