Http-kernel - The HttpKernel component provides a structured process for converting a Request into a Response.

Overview

HttpKernel Component

The HttpKernel component provides a structured process for converting a Request into a Response by making use of the EventDispatcher component. It's flexible enough to create full-stack frameworks, micro-frameworks or advanced CMS systems like Drupal.

Sponsor

The HttpKernel component for Symfony 5.4/6.0 is backed by Les-Tilleuls.coop.

Les-Tilleuls.coop is a team of 50+ Symfony experts who can help you design, develop and fix your projects. We provide a wide range of professional services including development, consulting, coaching, training and audits. We also are highly skilled in JS, Go and DevOps. We are a worker cooperative!

Help Symfony by sponsoring its development!

Resources

Comments
  • Symfony browser-kit in require dependencies

    Symfony browser-kit in require dependencies

    In Client.php there's browser kit used use Symfony\Component\BrowserKit

    However, it is not explicitely required by this lib and I think it should be. I think it's a sub dependency and therefore shouldn't be necessary to require it as direct dependency in my project.

    What are your thoughts?

    opened by simPod 3
  • catch \Throwable instead of \Exception

    catch \Throwable instead of \Exception

    Catching \Throwable instead of \Exception can be more versatile. In case of \TypeError kernel won't catch it with possibility to handle it with kernel.exception listener.

    opened by unixslayer 1
  • set Request locale from Accept-Language header being in an 'available_locales' array

    set Request locale from Accept-Language header being in an 'available_locales' array

    This $availableLocales value will come from a framework-bundle configuration entry available_locales along side default_locale and will be an (null by default) array.

    opened by GregoireHebert 1
  • Fix Apache's mod_expires Cache-Control issue

    Fix Apache's mod_expires Cache-Control issue

    Apaches's mod_expires is a widely used module to set HTTP caching headers. It allows you to set a default cache lifetime as well as lifetimes by mime_type.

    When an application server has set a Cache-Control header, mod_expires ignores this and sets its own, resulting in duplicate Cache-Control headers and conflicting information. It does this unless the application server sets an Expires header, in which case mod_expires does nothing. This is documented on the link above:

    When the Expires header is already part of the response generated by the server, for example when generated by a CGI script or proxied from an origin server, this module does not change or add an Expires or Cache-Control header.

    Symfony automatically sets a Cache-Control header if a session exists. This patch ensures it's respected by mod_expires.

    Example 1

    With the following Apache config:

    <IfModule mod_expires.c>
        ExpiresActive on
        ExpiresDefault                                      "access plus 1 month"
    </IfModule>
    

    The HTTP response headers are:

    Without the patch

    HTTP/1.1 200 OK
    Date: Fri, 06 Sep 2019 08:02:02 GMT
    Server: Apache/2.4.37 (Ubuntu)
    Cache-Control: max-age=0, must-revalidate, private
    Cache-Control: max-age=2592000
    Expires: Sun, 06 Oct 2019 08:02:00 GMT
    Vary: Accept-Encoding
    Content-Encoding: gzip
    Content-Length: 13099
    Connection: close
    Content-Type: text/html; charset=UTF-8
    

    With the patch

    HTTP/1.1 200 OK
    Date: Fri, 06 Sep 2019 08:21:34 GMT
    Server: Apache/2.4.37 (Ubuntu)
    Cache-Control: max-age=0, must-revalidate, private
    Expires: Fri, 06 Sep 2019 08:21:34 GMT
    Vary: Accept-Encoding
    Content-Encoding: gzip
    Content-Length: 13098
    Connection: close
    Content-Type: text/html; charset=UTF-8
    

    Example 2

    With the following Apache config:

    <IfModule mod_expires.c>
        ExpiresActive on
        ExpiresDefault                                      "access plus 1 month"
        ExpiresByType text/html                             "access plus 0 seconds"
    </IfModule>
    

    Without the patch

    HTTP/1.1 200 OK
    Date: Fri, 06 Sep 2019 08:18:40 GMT
    Server: Apache/2.4.37 (Ubuntu)
    Cache-Control: max-age=0, must-revalidate, private
    Cache-Control: max-age=0
    Expires: Fri, 06 Sep 2019 08:18:39 GMT
    Vary: Accept-Encoding
    Content-Encoding: gzip
    Content-Length: 13099
    Connection: close
    Content-Type: text/html; charset=UTF-8
    

    With the patch

    HTTP/1.1 200 OK
    Date: Fri, 06 Sep 2019 08:20:40 GMT
    Server: Apache/2.4.37 (Ubuntu)
    Cache-Control: max-age=0, must-revalidate, private
    Expires: Fri, 06 Sep 2019 08:20:40 GMT
    Vary: Accept-Encoding
    Content-Encoding: gzip
    Content-Length: 13100
    Connection: close
    Content-Type: text/html; charset=UTF-8
    
    opened by pbowyer 1
  • Added statusCode to parent::_contruct

    Added statusCode to parent::_contruct

    I ran into a case where I got a InvalidArgumentException(code: 0) with the message: The HTTP status code "0" is not valid while building the response for an exception of the type HttpException.

    As you can see, at the moment, the parent is getting the $code variable, which is not set. The thing that is being used is $statusCode.

    This leads to the following:

    $exception->getCode results in 0 $exception->getStatusCode results in a http-status code, like 404.

    Expected was the following:

    $exception->getCode results in 404 $exception->getStatusCode results 404.

    This problem only happens when people have a custom exception handler that expects that the inherited getCode method form the extended parent Exception class can be called...which in this case is being set to 0, even though it is a HttpException.

    So my proposed solution is to change the constructor from:

        public function __construct(int $statusCode, string $message = null, \Throwable $previous = null, array $headers = [], ?int $code = 0)
        {
            $this->statusCode = $statusCode;
            $this->headers = $headers;
    
            parent::__construct($message, $code, $previous);
        }
    

    to:

        public function __construct(int $statusCode, string $message = null, \Throwable $previous = null, array $headers = [], ?int $code = 0)
        {
            $this->statusCode = $statusCode;
            $this->headers = $headers;
    
            parent::__construct($message, $statusCode, $previous);
        }
    
    opened by xtrasmal 1
  • Allow user to set the project dir

    Allow user to set the project dir

    Currently, the project directory is defined by the location of the composer.json file.

    That file is not required in production, which therefore breaks the method getProjectDir (who sends back null). The offered solution, while working, requires the developer to implement it, and uses inheritance override, while a more aesthetic solution could be used.

    This does not fix the behaviour, but allows the developer to pass the project dir as a parameter.

    While this solution does not include BC break or anything, it is important to notice that it includes an optional parameter.

    Object instantiation in the framework bundle recipe could be updated as follow (in another PR):

    $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
    
    $kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG'], dirname(__DIR__));
    
    opened by tdutrion 1
  • ~2.6 makes that 2.8 be a valid version of this requirement but this m…

    ~2.6 makes that 2.8 be a valid version of this requirement but this m…

    …akes update PHP to a newer version

    All symfony 2.6 require PHP 5.3.3 minimum symfony add "symfony/http-kernel" 2.6.* version symfony/http-kernel add symfony/debug 2.8.* (because ~2.6) and symfony/debug 2.8.* require PHP 5.3.9 and that is the error I wanted fix that

    opened by emimarz 1
  • Remove _path from query parameters when fragment is a subrequest and request attributes are already set

    Remove _path from query parameters when fragment is a subrequest and request attributes are already set

    Without removing the _path query parameter, ESI handled through an actual proxy (Varnish, for example) behave differently than ESI handled when the proxy is not available (and thus the fragment is a subrequest instead of a master request).

    opened by cmenning 1
  • Update HttpCache.php

    Update HttpCache.php

    simplification... I guess the original Author was trying to pursue something like a martingale (doubling) strategy (or in this case the increment over a constant factor) but well ... he did not. Instead a constant wait time was introduced, which means the wait is simply executed a 100 times over (in the worst case). And so I do not see a need for "5000000" and "+= 50000" to remain here.

    opened by reenigneEsrever92 0
  • [HttpKernel] Fix coding standards

    [HttpKernel] Fix coding standards

    | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | no | License | MIT | Doc PR | no

    Hello,

    Here is a PR because I have noticed that the coding standards were not fully respected.

    I have added some phpdoc documentation and fix some conventions. Tell me if some things are not right, I would be happy to correct them.

    Regards,

    opened by 20uf 0
  • [HttpKernel] enabling cache-reloading when cache file is rebuilt

    [HttpKernel] enabling cache-reloading when cache file is rebuilt

    This allows the cache file to be deleted and thus rebuilt between Container builds in WebTestCase scenario, to enable testing of multiple configurations of the same application through WebTestCase.

    opened by stampycode 0
Releases(v6.2.4)
  • v6.2.4(Dec 29, 2022)

  • v6.1.10(Dec 29, 2022)

  • v6.0.18(Dec 29, 2022)

  • v5.4.18(Dec 29, 2022)

  • v6.2.3(Dec 28, 2022)

  • v6.1.9(Dec 28, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.1.8...v6.1.9)

    • bug #48651 AbstractSessionListener should not override the cache lifetime for private responses (rodmen)
    • bug #48624 Fix reading the SYMFONY_IDE env var (nicolas-grekas)
    • bug #48615 Fix getting the name of closures on PHP 8.1.11+ (nicolas-grekas)
    • bug #48346 In DateTimeValueResolver, convert previously defined date attribute to the expected class (GromNaN)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.17(Dec 28, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.0.16...v6.0.17)

    • bug #48651 AbstractSessionListener should not override the cache lifetime for private responses (rodmen)
    • bug #48615 Fix getting the name of closures on PHP 8.1.11+ (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.17(Dec 28, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v5.4.16...v5.4.17)

    • bug #48651 AbstractSessionListener should not override the cache lifetime for private responses (rodmen)
    • bug #48615 Fix getting the name of closures on PHP 8.1.11+ (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.2(Dec 16, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.2.1...v6.2.2)

    • bug #48651 AbstractSessionListener should not override the cache lifetime for private responses (rodmen)
    • bug #48624 Fix reading the SYMFONY_IDE env var (nicolas-grekas)
    • bug #48615 Fix getting the name of closures on PHP 8.1.11+ (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.1(Dec 6, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.2.0...v6.2.1)

    • bug #48509 Fix using entities with the #[Cache()] attribute (HypeMC)
    • bug #48346 In DateTimeValueResolver, convert previously defined date attribute to the expected class (GromNaN)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0(Nov 30, 2022)

  • v6.2.0-RC2(Nov 28, 2022)

  • v6.1.8(Nov 28, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.1.7...v6.1.8)

    • bug #48273 Fix message for unresovable arguments of invokable controllers (fancyweb)
    • bug #48172 Don’t try to wire Response argument with controller.service_arguments (MatTheCat)
    • bug #48110 Fix deprecation for DateTimeValueResolver with null on non-nullable argument (GromNaN)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.16(Nov 28, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.0.15...v6.0.16)

    • bug #48273 Fix message for unresovable arguments of invokable controllers (fancyweb)
    • bug #48172 Don’t try to wire Response argument with controller.service_arguments (MatTheCat)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.16(Nov 28, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v5.4.15...v5.4.16)

    • bug #48273 Fix message for unresovable arguments of invokable controllers (fancyweb)
    • bug #48172 Don’t try to wire Response argument with controller.service_arguments (MatTheCat)
    Source code(tar.gz)
    Source code(zip)
  • v4.4.49(Nov 28, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v4.4.48...v4.4.49)

    • bug #48273 Fix message for unresovable arguments of invokable controllers (fancyweb)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0-RC1(Nov 25, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.2.0-BETA3...v6.2.0-RC1)

    • bug #48273 Fix message for unresovable arguments of invokable controllers (fancyweb)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0-BETA3(Nov 19, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.2.0-BETA2...v6.2.0-BETA3)

    • bug #48172 Don’t try to wire Response argument with controller.service_arguments (MatTheCat)
    • bug #48110 Fix deprecation for DateTimeValueResolver with null on non-nullable argument (GromNaN)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0-BETA2(Oct 28, 2022)

  • v6.1.7(Oct 28, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.1.6...v6.1.7)

    • bug #47857 Fix empty request stack when terminating with exception (krzyc)
    • bug #47878 Remove EOL when using error_log() in HttpKernel Logger (cyve)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.15(Oct 28, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.0.14...v6.0.15)

    • bug #47857 Fix empty request stack when terminating with exception (krzyc)
    • bug #47878 Remove EOL when using error_log() in HttpKernel Logger (cyve)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.15(Oct 28, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v5.4.14...v5.4.15)

    • bug #47857 Fix empty request stack when terminating with exception (krzyc)
    • bug #47878 Remove EOL when using error_log() in HttpKernel Logger (cyve)
    Source code(tar.gz)
    Source code(zip)
  • v4.4.48(Oct 28, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v4.4.47...v4.4.48)

    • bug #47857 Fix empty request stack when terminating with exception (krzyc)
    • bug #47878 Remove EOL when using error_log() in HttpKernel Logger (cyve)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0-BETA1(Oct 24, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.1.6...v6.2.0-BETA1)

    • feature #47483 Make Logger implement DebugLoggerInterface (MatTheCat)
    • feature #47730 Ban DateTime from the codebase (WebMamba)
    • feature #47377 Use Accept-Language header even if there are no enabled locales (MatTheCat)
    • feature #38996 Remove the default values from setters with a nullable parameter (derrabus, nicolas-grekas)
    • feature #47236 Generate lazy-loading virtual proxies for non-ghostable lazy services (nicolas-grekas)
    • feature #47363 Replace ArgumentValueResolverInterface by ValueResolverInterface (nicolas-grekas)
    • feature #47094 Use xxh128 algorithm instead of sha256 for http cache store key (Pascal Woerde)
    • feature #46514 Add option to render Surrogate fragment with absolute URIs (Kern046)
    • feature #42355 Bugfix/last modified response strategy (aschempp)
    • feature #46880 Add #[Cache()] to describe the default HTTP cache headers on controllers (nicolas-grekas)
    • feature #46752 Use lazy-loading ghost object proxies out of the box (nicolas-grekas)
    • feature #46906 Add #[Template()] to describe how to render arrays returned by controllers (nicolas-grekas)
    • feature #46183 Hide sensitive information with SensitiveParameter attribute (GromNaN)
    • feature #46001 Add ControllerEvent::getAttributes() to handle attributes on controllers (nicolas-grekas)
    • feature #46763 Do not call terminate() on cache hit (Toflar)
    • feature #45997 Add deprecation warning to show HttpKernel::handle() will catch throwables (Nyholm)
    • feature #46614 Remove Debug component leftovers (chalasr)
    Source code(tar.gz)
    Source code(zip)
  • v6.1.6(Oct 12, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.1.5...v6.1.6)

    • bug #46956 Allow to specify null for exception mapping configuration values (andrew-demb)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.14(Oct 12, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.0.13...v6.0.14)

    • bug #46956 Allow to specify null for exception mapping configuration values (andrew-demb)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.14(Oct 12, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v5.4.13...v5.4.14)

    • bug #46956 Allow to specify null for exception mapping configuration values (andrew-demb)
    Source code(tar.gz)
    Source code(zip)
  • v4.4.47(Oct 12, 2022)

  • v6.1.5(Sep 30, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.1.4...v6.1.5)

    • bug #47675 Use Accept-Language header even if there are no enabled locales (MatTheCat)
    • bug #47491 Prevent exception in RequestDataCollector if request stack is empty (aschempp)
    • bug #47435 lock when writting profiles (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.13(Sep 30, 2022)

    Changelog (https://github.com/symfony/http-kernel/compare/v6.0.12...v6.0.13)

    • bug #47491 Prevent exception in RequestDataCollector if request stack is empty (aschempp)
    • bug #47435 lock when writting profiles (nicolas-grekas)
    Source code(tar.gz)
    Source code(zip)
pedre-response is a standard structure of json response

PedreResponse It's very important to use same structure for responses in large projects that PedreResponse package can do it for you. PedreResponse is

Pedram Rezaei 2 Dec 22, 2021
OpenAPI(v3) Validators for Symfony http-foundation, using `league/openapi-psr7-validator` and `symfony/psr-http-message-bridge`.

openapi-http-foundation-validator OpenAPI(v3) Validators for Symfony http-foundation, using league/openapi-psr7-validator and symfony/psr-http-message

n1215 2 Nov 19, 2021
Extended response classes for Rest API clients/SDKs

Rest Response Extended response classes for Rest API clients/SDKs. About This package is intended to be component of SDKs so the responses can be easi

Ilesanmi Olawale Adedotun 2 Mar 28, 2022
The PasswordHasher component provides password hashing utilities.

PasswordHasher Component The PasswordHasher component provides secure password hashing utilities. Getting Started $ composer require symfony/password-

Symfony 482 Dec 29, 2022
Provides a Middleware to integration Tideways into Symfony Messenger Processing

Tideways Middleware for Symfony Messenger This package is currently under development and might be moved into the Tideways PHP Extension or stay indep

Tideways 6 Jul 5, 2022
Provides tools for building modules that integrate Nosto into your e-commerce platform

php-sdk Provides tools for building modules that integrate Nosto into your e-commerce platform. Requirements The Nosto PHP SDK requires at least PHP v

Nosto 5 Dec 21, 2021
A request rate limiter for Laravel 5.

Alt Three Throttle An request rate limiter for Laravel 5. Installation This version requires PHP 7.1 or 7.2, and supports Laravel 5.5 - 5.7 only. To g

Alt Three 41 Jan 3, 2022
PHP implementation of JSON schema. Fork of the http://jsonschemaphpv.sourceforge.net/ project

JSON Schema for PHP A PHP Implementation for validating JSON Structures against a given Schema with support for Schemas of Draft-3 or Draft-4. Feature

Justin Rainbow 3.4k Dec 26, 2022
A PSR-15 middleware adapter for react/http

A PSR-15 middleware adapter for react/http Wraps PSR-15 middleware into coroutines using RecoilPHP making them usable within react/http as middleware.

Friends of ReactPHP 22 Nov 12, 2022
The Yaml component loads and dumps YAML files.

Yaml Component The Yaml component loads and dumps YAML files. Resources Documentation Contributing Report issues and send Pull Requests in the main Sy

Symfony 3.5k Dec 30, 2022
Monorepo of the PoP project, including: a server-side component model in PHP, a GraphQL server, a GraphQL API plugin for WordPress, and a website builder

PoP PoP is a monorepo containing several projects. The GraphQL API for WordPress plugin GraphQL API for WordPress is a forward-looking and powerful Gr

Leonardo Losoviz 265 Jan 7, 2023
Fork of Symfony Rate Limiter Component for Symfony 4

Rate Limiter Component Fork (Compatible with Symfony <=4.4) The Rate Limiter component provides a Token Bucket implementation to rate limit input and

AvaiBook by idealista 4 Apr 19, 2022
Enter-to-the-Matrix-with-Symfony-Console - Reproduction of the "Matrix characterfall" effect with the Symfony Console component.

Enter to the Matrix (with Symfony Console) Reproduction of the "Matrix characterfall" effect with the Symfony Console component. Run Clone the project

Yoan Bernabeu 23 Aug 28, 2022
The BrowserKit component simulates the behavior of a web browser

BrowserKit Component The BrowserKit component simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms

Symfony 2.7k Dec 29, 2022
The server component of API Platform: hypermedia and GraphQL APIs in minutes

API Platform Core API Platform Core is an easy to use and powerful system to create hypermedia-driven REST and GraphQL APIs. It is a component of the

API Platform 2.2k Dec 27, 2022
Stepup Middleware - This component is part of "Step-up Authentication as-a Service".

Step-up Middleware This component is part of "Step-up Authentication as-a Service". See Stepup-Deploy for an overview and installation instructions fo

OpenConext 4 Nov 2, 2022
Monorepo of the PoP project, including: a server-side component model in PHP, a GraphQL server, a GraphQL API plugin for WordPress, and a website builder

PoP PoP is a monorepo containing several projects. The GraphQL API for WordPress plugin GraphQL API for WordPress is a forward-looking and powerful Gr

Leonardo Losoviz 265 Jan 7, 2023
Raidbots API wrapper which incorporates existing reports and static data into your project.

Raidbots API Raidbots API wrapper which incorporates existing reports and static data into your project. Usage use Logiek\Raidbots\Client; $client =

Logiek 2 Dec 23, 2021
Laravel library to convert your models into API responses.

Laravel Scene Laravel library to convert your models into API responses. Why a transformation library? By default you can use the default implementati

Ahmed Azaan 27 Nov 23, 2022