Search code examples
phplaravellaravel-5laravel-5.3

Laravel where is the request bound into the container?


I know Laravel binds the request into the container since the helper method resolves it from the container like so:

function request($key = null, $default = null)
{
    if (is_null($key)) {
        return app('request');
    }

    if (is_array($key)) {
        return app('request')->only($key);
    }

    return app('request')->input($key, $default);
}

At what exact point is the request being bound into the container though? I can't seem to find it.


Solution

  • The Laravel request object is bound and rebound from multiple service providers.

    You can find this in the Laravel framework as below:

    Kernel.php, SetRequestForConsole.php and AuthServiceProvider.php