App
in package
The framework kernel class.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Class constructor.
- getContainer() : Container|null
- Get container object.
- run() : mixed
- Run the application.
- addDependencyInjection() : mixed
- Add dependency injection container to use between classes.
- checkRequirements() : mixed
- Check requirements such as constants, PHP version.
- loadAfterMiddleware() : mixed
- Load [after] middleware from config to run after the application started.
- loadBeforeMiddleware() : string|null
- Load [before] middleware from config to run before the application start.
- processController() : string|null
- Process the controller and get the output content.
- processHeaders() : mixed
- Process headers.
- processRoute() : array<string|int, mixed>
- Process route.
- getMiddlewareConfig() : array<string|int, mixed>
- Get middleware configuration from main app and modules.
- getRouteErrorConfig() : array<string|int, mixed>
- Get routes for error handler from main app and maybe replaced by other modules.
Properties
$Config
protected
Config
$Config
The system configuration class.
$Container
protected
Container
$Container
The DI container.
$Logger
protected
Logger
$Logger
Logger class.
Methods
__construct()
Class constructor.
public
__construct() : mixed
getContainer()
Get container object.
public
getContainer() : Container|null
Return values
Container|null —Return container object or null
if it was not exists.
run()
Run the application.
public
run() : mixed
addDependencyInjection()
Add dependency injection container to use between classes.
protected
addDependencyInjection() : mixed
checkRequirements()
Check requirements such as constants, PHP version.
protected
checkRequirements() : mixed
Maybe set constant or throw the exception if not defined.
This method was called from __construct()
.
Tags
loadAfterMiddleware()
Load [after] middleware from config to run after the application started.
protected
loadAfterMiddleware(string|null $response) : mixed
Parameters
- $response : string|null
-
The output content from application controller.
loadBeforeMiddleware()
Load [before] middleware from config to run before the application start.
protected
loadBeforeMiddleware() : string|null
The middleware is anything between kernel and application (MVC in this case).
Tags
Return values
string|null —Return the response content (before application controller start).
processController()
Process the controller and get the output content.
protected
processController(string $handler, array<string|int, mixed> $arguments) : string|null
This method process 404 error if class, controller, method - one of these was not found.
Parameters
- $handler : string
-
Route handler.
- $arguments : array<string|int, mixed>
-
Route arguments.
Return values
string|null —Return output content of that controller.
processHeaders()
Process headers.
protected
processHeaders([string|null $response = '' ]) : mixed
Parameters
- $response : string|null = ''
-
The output content from application controller.
processRoute()
Process route.
protected
processRoute() : array<string|int, mixed>
Also process 404, 405 error.
Return values
array<string|int, mixed> —Return array these keys:
status
(string) The status of the route. Example: found, notfound, methodnotallowed.
handler
(string) The handler for this route. It is controller:method.
args
(array, optional) The route arguments. Maybe available if route was found.
getMiddlewareConfig()
Get middleware configuration from main app and modules.
private
getMiddlewareConfig([string $middlewareConfigPart = 'beforeMiddleware' ]) : array<string|int, mixed>
Parameters
- $middlewareConfigPart : string = 'beforeMiddleware'
-
Middleware configuration part. Accept 'beforeMiddleware', 'afterMiddleware'.
Tags
Return values
array<string|int, mixed> —Return middlewares from selected part.
getRouteErrorConfig()
Get routes for error handler from main app and maybe replaced by other modules.
private
getRouteErrorConfig() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —Return configuration of routes for error handler.