class Kernel implements Kernel (View source)

Traits

Properties

protected Application $app

The application implementation.

protected Router $router

The router instance.

protected string[] $bootstrappers

The bootstrap classes for the application.

protected array<int,class-string|string> $middleware

The application's middleware stack.

protected array<string,array<int,class-string|string>> $middlewareGroups

The application's route middleware groups.

protected array<string,class-string|string> deprecated $routeMiddleware

The application's route middleware.

protected array<string,class-string|string> $middlewareAliases

The application's middleware aliases.

protected array $requestLifecycleDurationHandlers

All of the registered request duration handlers.

protected Carbon|null $requestStartedAt

When the kernel starting handling the current request.

protected string[] $middlewarePriority

The priority-sorted list of middleware.

Methods

int
secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

int
availableAt(DateTimeInterface|DateInterval|int $delay = 0)

Get the "available at" UNIX timestamp.

parseDateInterval(DateTimeInterface|DateInterval|int $delay)

If the given value is an interval, convert it to a DateTime instance.

int
currentTime()

Get the current system time as a UNIX timestamp.

string
runTimeForHumans(float $startTime, float $endTime = null)

Given a start time, format the total run time for human readability.

void
__construct(Application $app, Router $router)

Create a new HTTP kernel instance.

Response
handle(Request $request)

Handle an incoming HTTP request.

sendRequestThroughRouter(Request $request)

Send the given request through the middleware / router.

void
bootstrap()

Bootstrap the application for HTTP requests.

dispatchToRouter()

Get the route dispatcher callback.

void
terminate(Request $request, Response $response)

Call the terminate method on any terminable middleware.

void
terminateMiddleware(Request $request, Response $response)

Call the terminate method on any terminable middleware.

void
whenRequestLifecycleIsLongerThan(DateTimeInterface|CarbonInterval|float|int $threshold, callable $handler)

Register a callback to be invoked when the requests lifecycle duration exceeds a given amount of time.

Carbon|null
requestStartedAt()

When the request being handled started.

array
gatherRouteMiddleware(Request $request)

Gather the route middleware for the given request.

array
parseMiddleware(string $middleware)

Parse a middleware string to get the name and parameters.

bool
hasMiddleware(string $middleware)

Determine if the kernel has a given middleware.

$this
prependMiddleware(string $middleware)

Add a new middleware to the beginning of the stack if it does not already exist.

$this
pushMiddleware(string $middleware)

Add a new middleware to end of the stack if it does not already exist.

$this
prependMiddlewareToGroup(string $group, string $middleware)

Prepend the given middleware to the given middleware group.

$this
appendMiddlewareToGroup(string $group, string $middleware)

Append the given middleware to the given middleware group.

$this
prependToMiddlewarePriority(string $middleware)

Prepend the given middleware to the middleware priority list.

$this
appendToMiddlewarePriority(string $middleware)

Append the given middleware to the middleware priority list.

$this
addToMiddlewarePriorityBefore(array|string $before, string $middleware)

Add the given middleware to the middleware priority list before other middleware.

$this
addToMiddlewarePriorityAfter(array|string $after, string $middleware)

Add the given middleware to the middleware priority list after other middleware.

$this
addToMiddlewarePriorityRelative(string|array $existing, string $middleware, bool $after = true)

Add the given middleware to the middleware priority list relative to other middleware.

void
syncMiddlewareToRouter()

Sync the current state of the middleware to the router.

array
getMiddlewarePriority()

Get the priority-sorted list of middleware.

array
bootstrappers()

Get the bootstrap classes for the application.

void
reportException(Throwable $e)

Report the exception to the exception handler.

Response
renderException(Request $request, Throwable $e)

Render the exception to a response.

array
getGlobalMiddleware()

Get the application's global middleware.

$this
setGlobalMiddleware(array $middleware)

Set the application's global middleware.

array
getMiddlewareGroups()

Get the application's route middleware groups.

$this
setMiddlewareGroups(array $groups)

Set the application's middleware groups.

array
getRouteMiddleware() deprecated

Get the application's route middleware aliases.

array
getMiddlewareAliases()

Get the application's route middleware aliases.

$this
setMiddlewareAliases(array $aliases)

Set the application's route middleware aliases.

$this
setMiddlewarePriority(array $priority)

Set the application's middleware priority.

getApplication()

Get the Laravel application instance.

$this
setApplication(Application $app)

Set the Laravel application instance.

Details

protected int secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

protected int availableAt(DateTimeInterface|DateInterval|int $delay = 0)

Get the "available at" UNIX timestamp.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

protected DateTimeInterface|int parseDateInterval(DateTimeInterface|DateInterval|int $delay)

If the given value is an interval, convert it to a DateTime instance.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

DateTimeInterface|int

protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

protected string runTimeForHumans(float $startTime, float $endTime = null)

Given a start time, format the total run time for human readability.

Parameters

float $startTime
float $endTime

Return Value

string

void __construct(Application $app, Router $router)

Create a new HTTP kernel instance.

Parameters

Application $app
Router $router

Return Value

void

Response handle(Request $request)

Handle an incoming HTTP request.

Parameters

Request $request

Return Value

Response

protected Response sendRequestThroughRouter(Request $request)

Send the given request through the middleware / router.

Parameters

Request $request

Return Value

Response

void bootstrap()

Bootstrap the application for HTTP requests.

Return Value

void

protected Closure dispatchToRouter()

Get the route dispatcher callback.

Return Value

Closure

void terminate(Request $request, Response $response)

Call the terminate method on any terminable middleware.

Parameters

Request $request
Response $response

Return Value

void

protected void terminateMiddleware(Request $request, Response $response)

Call the terminate method on any terminable middleware.

Parameters

Request $request
Response $response

Return Value

void

void whenRequestLifecycleIsLongerThan(DateTimeInterface|CarbonInterval|float|int $threshold, callable $handler)

Register a callback to be invoked when the requests lifecycle duration exceeds a given amount of time.

Parameters

DateTimeInterface|CarbonInterval|float|int $threshold
callable $handler

Return Value

void

Carbon|null requestStartedAt()

When the request being handled started.

Return Value

Carbon|null

protected array gatherRouteMiddleware(Request $request)

Gather the route middleware for the given request.

Parameters

Request $request

Return Value

array

protected array parseMiddleware(string $middleware)

Parse a middleware string to get the name and parameters.

Parameters

string $middleware

Return Value

array

bool hasMiddleware(string $middleware)

Determine if the kernel has a given middleware.

Parameters

string $middleware

Return Value

bool

$this prependMiddleware(string $middleware)

Add a new middleware to the beginning of the stack if it does not already exist.

Parameters

string $middleware

Return Value

$this

$this pushMiddleware(string $middleware)

Add a new middleware to end of the stack if it does not already exist.

Parameters

string $middleware

Return Value

$this

$this prependMiddlewareToGroup(string $group, string $middleware)

Prepend the given middleware to the given middleware group.

Parameters

string $group
string $middleware

Return Value

$this

Exceptions

InvalidArgumentException

$this appendMiddlewareToGroup(string $group, string $middleware)

Append the given middleware to the given middleware group.

Parameters

string $group
string $middleware

Return Value

$this

Exceptions

InvalidArgumentException

$this prependToMiddlewarePriority(string $middleware)

Prepend the given middleware to the middleware priority list.

Parameters

string $middleware

Return Value

$this

$this appendToMiddlewarePriority(string $middleware)

Append the given middleware to the middleware priority list.

Parameters

string $middleware

Return Value

$this

$this addToMiddlewarePriorityBefore(array|string $before, string $middleware)

Add the given middleware to the middleware priority list before other middleware.

Parameters

array|string $before
string $middleware

Return Value

$this

$this addToMiddlewarePriorityAfter(array|string $after, string $middleware)

Add the given middleware to the middleware priority list after other middleware.

Parameters

array|string $after
string $middleware

Return Value

$this

protected $this addToMiddlewarePriorityRelative(string|array $existing, string $middleware, bool $after = true)

Add the given middleware to the middleware priority list relative to other middleware.

Parameters

string|array $existing
string $middleware
bool $after

Return Value

$this

protected void syncMiddlewareToRouter()

Sync the current state of the middleware to the router.

Return Value

void

array getMiddlewarePriority()

Get the priority-sorted list of middleware.

Return Value

array

protected array bootstrappers()

Get the bootstrap classes for the application.

Return Value

array

protected void reportException(Throwable $e)

Report the exception to the exception handler.

Parameters

Throwable $e

Return Value

void

protected Response renderException(Request $request, Throwable $e)

Render the exception to a response.

Parameters

Request $request
Throwable $e

Return Value

Response

array getGlobalMiddleware()

Get the application's global middleware.

Return Value

array

$this setGlobalMiddleware(array $middleware)

Set the application's global middleware.

Parameters

array $middleware

Return Value

$this

array getMiddlewareGroups()

Get the application's route middleware groups.

Return Value

array

$this setMiddlewareGroups(array $groups)

Set the application's middleware groups.

Parameters

array $groups

Return Value

$this

array getRouteMiddleware() deprecated

deprecated

Get the application's route middleware aliases.

Return Value

array

array getMiddlewareAliases()

Get the application's route middleware aliases.

Return Value

array

$this setMiddlewareAliases(array $aliases)

Set the application's route middleware aliases.

Parameters

array $aliases

Return Value

$this

$this setMiddlewarePriority(array $priority)

Set the application's middleware priority.

Parameters

array $priority

Return Value

$this

Application getApplication()

Get the Laravel application instance.

Return Value

Application

$this setApplication(Application $app)

Set the Laravel application instance.

Parameters

Application $app

Return Value

$this