Application
in package
Application
Table of Contents
Constants
- DEFAULT_PAGE_NOT_FOUND_HANDLER = '\\Arikaim\\Core\\Controllers\\ErrorController:showPageNotFound'
- Sefault controller class for page not found error
- DEFUALT_ERROR_HANDLER = '\\Arikaim\\Core\\Framework\\ErrorHandler'
- Default error handler class
Properties
- $container : ContainerInterface
- App container
- $errorHandler : object|null
- Error handler
- $errorHandlerClass : string|null
- Error handler class
- $factory : object
- Psr17 factory
- $middlewares : array<string|int, mixed>
- Global middlewares
- $router : RouterInterface
- Router
Methods
- __construct() : mixed
- Constructor
- addMiddleware() : void
- Add global middleware
- addRoute() : void
- Add route
- addRouteMiddleware() : void
- Add route middleware
- createResponse() : ResponseInterface
- Create response
- emit() : void
- Emit response
- getContainer() : ContainerInterface
- Get container
- getFactory() : object
- Return psr17 factory
- getRouter() : RouterInterface
- Get router
- handleRequest() : ResponseInterface
- Handle http request
- resolveCallable() : array<string|int, mixed>
- Resolve route handler
- run() : void
- Run application
- setMiddlewares() : void
- Set middlewares
- setRouter() : void
- Swt router
- handleException() : ResponseInterface
- Render app exception
- handleRoute() : ResponseInterface
- Execute route handler
- resolveRouteMiddleware() : MiddlewareInterface
- Create middleware instance
- emitHeaders() : void
- Emit headers
- resolveErrorHandler() : void
- Create error handler if not set
Constants
DEFAULT_PAGE_NOT_FOUND_HANDLER
Sefault controller class for page not found error
public
mixed
DEFAULT_PAGE_NOT_FOUND_HANDLER
= '\\Arikaim\\Core\\Controllers\\ErrorController:showPageNotFound'
DEFUALT_ERROR_HANDLER
Default error handler class
public
mixed
DEFUALT_ERROR_HANDLER
= '\\Arikaim\\Core\\Framework\\ErrorHandler'
Properties
$container
App container
protected
ContainerInterface
$container
$errorHandler
Error handler
protected
object|null
$errorHandler
= null
$errorHandlerClass
Error handler class
protected
string|null
$errorHandlerClass
$factory
Psr17 factory
protected
object
$factory
$middlewares
Global middlewares
protected
array<string|int, mixed>
$middlewares
= []
$router
Router
protected
RouterInterface
$router
Methods
__construct()
Constructor
public
__construct(ContainerInterface $container, RouterInterface $router[, string|null $errorHandlerClass = null ][, object|null $factory = null ]) : mixed
Parameters
- $container : ContainerInterface
- $router : RouterInterface
- $errorHandlerClass : string|null = null
- $factory : object|null = null
addMiddleware()
Add global middleware
public
addMiddleware(object|string $middleware[, array<string|int, mixed> $options = [] ]) : void
Parameters
- $middleware : object|string
- $options : array<string|int, mixed> = []
addRoute()
Add route
public
addRoute(string $method, string $pattern, string $handlerClass[, array<string|int, mixed> $options = [] ][, string|int|null $routeId = null ]) : void
Parameters
- $method : string
- $pattern : string
- $handlerClass : string
- $options : array<string|int, mixed> = []
- $routeId : string|int|null = null
addRouteMiddleware()
Add route middleware
public
addRouteMiddleware(string $method, string $routeHandlerClass, string|object $middleware) : void
Parameters
- $method : string
- $routeHandlerClass : string
- $middleware : string|object
createResponse()
Create response
public
createResponse([int $status = 200 ]) : ResponseInterface
Parameters
- $status : int = 200
Return values
ResponseInterfaceemit()
Emit response
public
static emit(ResponseInterface $response) : void
Parameters
- $response : ResponseInterface
getContainer()
Get container
public
getContainer() : ContainerInterface
Return values
ContainerInterfacegetFactory()
Return psr17 factory
public
getFactory() : object
Return values
objectgetRouter()
Get router
public
getRouter() : RouterInterface
Return values
RouterInterfacehandleRequest()
Handle http request
public
handleRequest(ServerRequestInterface $request, ResponseInterface $response[, array<string|int, mixed>|null $options = [] ]) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $response : ResponseInterface
- $options : array<string|int, mixed>|null = []
Return values
ResponseInterfaceresolveCallable()
Resolve route handler
public
resolveCallable(string $callable, ResponseInterface $response) : array<string|int, mixed>
Parameters
- $callable : string
- $response : ResponseInterface
Return values
array<string|int, mixed>run()
Run application
public
run([ServerRequestInterface|null $request = null ][, array<string|int, mixed> $options = [] ]) : void
Parameters
- $request : ServerRequestInterface|null = null
- $options : array<string|int, mixed> = []
setMiddlewares()
Set middlewares
public
setMiddlewares(array<string|int, mixed> $middlewares) : void
Parameters
- $middlewares : array<string|int, mixed>
setRouter()
Swt router
public
setRouter(RouterInterface $router) : void
Parameters
- $router : RouterInterface
handleException()
Render app exception
protected
handleException(Throwable $exception, ServerRequestInterface $request, ResponseInterface $response) : ResponseInterface
Parameters
- $exception : Throwable
- $request : ServerRequestInterface
- $response : ResponseInterface
Return values
ResponseInterfacehandleRoute()
Execute route handler
protected
handleRoute(array<string|int, mixed> $route, ServerRequestInterface $request, ResponseInterface $response) : ResponseInterface
Parameters
- $route : array<string|int, mixed>
- $request : ServerRequestInterface
- $response : ResponseInterface
Return values
ResponseInterfaceresolveRouteMiddleware()
Create middleware instance
protected
resolveRouteMiddleware(string $middlewareClass, array<string|int, mixed> $options) : MiddlewareInterface
Parameters
- $middlewareClass : string
- $options : array<string|int, mixed>
Return values
MiddlewareInterfaceemitHeaders()
Emit headers
private
static emitHeaders(ResponseInterface $response) : void
Parameters
- $response : ResponseInterface
resolveErrorHandler()
Create error handler if not set
private
resolveErrorHandler() : void