Pionia Core

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
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

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 = []

Methods

run()

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()

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()

private mergeAuthenticationsFromSettings() : void
Tags
throws
Exception

mergeMiddlewaresFromSettings()

private mergeMiddlewaresFromSettings() : void
Tags
throws
Exception

resolveAuthenticationBackend()

Resolves all authentication middlewares using the `authenticationBackendWorker` method

private resolveAuthenticationBackend(Request $request) : Request
Parameters
$request : Request
Tags
throws
Exception
Return values
Request

resolveFrontEnd()

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
$request : Request
$response : Response|null = null
Tags
throws
Exception
Return values
Request

serveSpa()

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


        
On this page

Search results