Menu

## CoreKernel
in package

CoreKernel.php : 55

This is the core kernel that handles all the request processing and middleware execution

It is executes the entire request cycle.

The request cycle is as follows:

    1. Resolve all middlewares against the request only
    2. Resolve all authentication backends till we have a user or we run out of backends
    3. Resolve the request and enter the controller
    4. Resolve all middlewares again but this time against the request and response since we have both
    5. Return the response to the client

It also catches all exceptions and returns a 200 ok response with error code 500

##### Tags

author

  Jet - ezrajet9@gmail.com

### Table of Contents

#### Properties

$authBackends : mixed
$context : mixed
$matcher : mixed
$middleware : mixed
$routes : mixed
$authBackends : array<string|int, mixed>
$context : RequestContext|null
$matcher : UrlMatcher|null
$middleware : array<string|int, mixed>
$routes : BaseRoutes

#### Methods

__construct() : mixed
resolveCors() : void
run() : Response
  Bootstraps the entire application It automatically resolves the request internally, middlewares, authentication backends and the controller
authenticationBackendWorker() : Request
  This will run until any of the backends successfully authenticates the user
mergeAuthenticationsFromSettings() : void
mergeMiddlewaresFromSettings() : void
resolve() : Response
resolveAuthenticationBackend() : Request
  Resolves all authentication middlewares using the `authenticationBackendWorker` method
resolveFrontEnd() : void
  Resolves the front end if the request is a get request and the path is not an api path
resolveMiddlewares() : Request
  Runs every registered middleware pre and post controller execution. Exposing both the request and response the middleware
serveSpa() : void
  Serves Single Page Applications. This is useful for serving the front end from the root of the project.

### Properties

#### $authBackends

CoreKernel.php : 0
`public mixed $authBackends`

array - Array of authentication backends

#### $context

CoreKernel.php : 0
`public mixed $context`

RequestContext - Instance of the request context

#### $matcher

CoreKernel.php : 0
`public mixed $matcher`

UrlMatcher - Instance of the url matcher

#### $middleware

CoreKernel.php : 0
`public mixed $middleware`

array - Array of middleware classes

#### $routes

CoreKernel.php : 0
`public mixed $routes`

BaseRoutes - Instance of the base routes

#### $authBackends

CoreKernel.php : 63
`private array<string|int, mixed> $authBackends = []`

#### $context

CoreKernel.php : 57
`private RequestContext|null $context = null`

#### $matcher

CoreKernel.php : 58
`private UrlMatcher|null $matcher = null`

#### $middleware

CoreKernel.php : 61
`private array<string|int, mixed> $middleware = []`

#### $routes read-only

CoreKernel.php : 80
`private BaseRoutes $routes`

### Methods

#### __construct()

CoreKernel.php : 79
`public __construct(BaseRoutes $routes) : mixed`

##### Parameters

$routes : BaseRoutes

#### resolveCors()

CoreKernel.php : 65
`public resolveCors() : void`

#### run()

CoreKernel.php : 195

Bootstraps the entire application It automatically resolves the request internally, middlewares, authentication backends and the controller

`public run() : Response`

##### Tags

since
  1.1.1
  - This method was added to replace the handle method. The handle method will be removed in future versions

##### Return values

Response

#### authenticationBackendWorker()

CoreKernel.php : 258

This will run until any of the backends successfully authenticates the user

`private authenticationBackendWorker(Request $request, array<string|int, mixed> $backends) : Request`

or until all the backends are complete

##### Parameters

$request : Request
$backends : array<string|int, mixed>

##### Return values

Request

#### mergeAuthenticationsFromSettings()

CoreKernel.php : 108
`private mergeAuthenticationsFromSettings() : void`

##### Tags

throws
  Exception

#### mergeMiddlewaresFromSettings()

CoreKernel.php : 87
`private mergeMiddlewaresFromSettings() : void`

##### Tags

throws
  Exception

#### resolve()

CoreKernel.php : 130
`private resolve(Request $request) : Response`

##### Parameters

$request : Request

##### Tags

throws
  Exception

##### Return values

Response

#### resolveAuthenticationBackend()

CoreKernel.php : 239

Resolves all authentication middlewares using the `authenticationBackendWorker` method

`private resolveAuthenticationBackend(Request $request) : Request`

##### Parameters

$request : Request

##### Tags

throws
  Exception

##### Return values

Request

#### resolveFrontEnd()

CoreKernel.php : 293

Resolves the front end if the request is a get request and the path is not an api path

`private resolveFrontEnd(Request $request) : void`

Using any frontend of your choice, you can serve the front end from the root of the project

##### Parameters

$request : Request

#### resolveMiddlewares()

CoreKernel.php : 221

Runs every registered middleware pre and post controller execution. Exposing both the request and response the middleware

`private resolveMiddlewares(Request $request[, Response|null $response = null ]) : Request`

##### Parameters

$request : Request
$response : Response|null = null

##### Tags

throws
  Exception

##### Return values

Request

#### serveSpa()

CoreKernel.php : 311

Serves Single Page Applications. This is useful for serving the front end from the root of the project.

`private serveSpa() : void`

Handles also cases where users refreshes the url from relative paths to the frontend

## Search results