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
Bart van den Burg e6bb156f48 remove realpath call
I'm trying to create an executable phar archive from a Symfony application, but when I run the phar, it fails to find any commands because of this php bug/feature:

https://bugs.php.net/bug.php?id=52769

After this change, my archive works just like a normal app/console call
2012-12-11 11:18:21 +01:00
..
Bundle remove realpath call 2012-12-11 11:18:21 +01:00
CacheWarmer fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02:00
Config fixed phpdoc @param alignment 2012-05-15 18:56:32 +02:00
Controller fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02:00
DataCollector fixed stringification of array objects in RequestDataCollector (closes #5295) 2012-09-21 08:32:55 +02:00
Debug fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02:00
DependencyInjection fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02:00
Event [HttpKernel][Translator] Fixed type-hints 2012-10-04 16:11:30 +01:00
EventListener fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02:00
Exception fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02:00
HttpCache Add check to Store::unlock to ensure file exists 2012-08-29 16:45:40 +10:00
Log fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02:00
Profiler [Profiler]Use the abstract method to get client IP 2012-09-17 16:33:21 +03:00
Util fixed phpdoc @param alignment 2012-05-15 18:56:32 +02:00
Client.php fixed phpdoc @param alignment 2012-05-15 18:56:32 +02:00
composer.json removed the version attribute in all composer.json files 2012-01-05 14:51:20 +01:00
HttpKernel.php fixed phpdoc @param alignment 2012-05-15 18:56:32 +02:00
HttpKernelInterface.php fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02:00
Kernel.php bumped Symfony version to 2.0.19-DEV 2012-12-02 18:59:42 +01:00
KernelEvents.php [HttpKernel] tagged public @api 2011-07-20 10:14:31 +02:00
KernelInterface.php fixed CS (mainly method signatures) 2012-07-09 14:43:50 +02: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