CoreKernel
in package
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
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
public
mixed
$authBackends
array - Array of authentication backends
$context
public
mixed
$context
RequestContext - Instance of the request context
$matcher
public
mixed
$matcher
UrlMatcher - Instance of the url matcher
$middleware
public
mixed
$middleware
array - Array of middleware classes
$routes
public
mixed
$routes
BaseRoutes - Instance of the base routes
$authBackends
private
array<string|int, mixed>
$authBackends
= []
$context
private
RequestContext|null
$context
= null
$matcher
private
UrlMatcher|null
$matcher
= null
$middleware
private
array<string|int, mixed>
$middleware
= []
$routes read-only
private
BaseRoutes
$routes
Methods
__construct()
public
__construct(BaseRoutes $routes) : mixed
Parameters
- $routes : BaseRoutes
resolveCors()
public
resolveCors() : void
run()
Bootstraps the entire application It automatically resolves the request internally, middlewares, authentication backends and the controller
public
run() : Response
Tags
Return values
ResponseauthenticationBackendWorker()
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
RequestmergeAuthenticationsFromSettings()
private
mergeAuthenticationsFromSettings() : void
Tags
mergeMiddlewaresFromSettings()
private
mergeMiddlewaresFromSettings() : void
Tags
resolve()
private
resolve(Request $request) : Response
Parameters
- $request : Request
Tags
Return values
ResponseresolveAuthenticationBackend()
Resolves all authentication middlewares using the `authenticationBackendWorker` method
private
resolveAuthenticationBackend(Request $request) : Request
Parameters
- $request : Request
Tags
Return values
RequestresolveFrontEnd()
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()
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
Tags
Return values
RequestserveSpa()
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