App
in package
Micro PHP Application
Table of Contents
- CONFIG_BASE_URL = 'app.base_url'
- CONFIG_ENVIRONMENT = 'app.environment'
- CONFIG_ROOT_PATH = 'app.root_path'
- PRODUCTION_ENVIRONMENT = 'prod'
- $config : Config
- $configPaths : array<string|int, string>
- $exitOnFinish : bool
- $logger : Logger
- $middlewares : array<string|int, Middleware>
- Stores the middleware class names in a list
- __construct() : mixed
- addMiddleware() : mixed
- Adds a middleware
- finish() : null
- Finishes the application
- fullInit() : mixed
- Fully initializes the application
- fullProcess() : mixed
- Calls the `process()` method within a try/catch, handles exception with the `handleException()` method
- init() : mixed
- Abstract function for initialize the application
- process() : mixed
- Abstract function for processing the application
- handleException() : mixed
- Handles the exception
- loadConfigs() : mixed
- Loads all of the configs by the `$configPaths`
- runMiddlewares() : mixed
- Runs all of the added middlewares
Constants
CONFIG_BASE_URL
public
mixed
CONFIG_BASE_URL
= 'app.base_url'
CONFIG_ENVIRONMENT
public
mixed
CONFIG_ENVIRONMENT
= 'app.environment'
CONFIG_ROOT_PATH
public
mixed
CONFIG_ROOT_PATH
= 'app.root_path'
PRODUCTION_ENVIRONMENT
public
mixed
PRODUCTION_ENVIRONMENT
= 'prod'
Properties
$config
protected
Config
$config
$configPaths
protected
array<string|int, string>
$configPaths
$exitOnFinish
protected
bool
$exitOnFinish
= true
$logger
protected
Logger
$logger
$middlewares
Stores the middleware class names in a list
protected
array<string|int, Middleware>
$middlewares
= []
Methods
__construct()
public
__construct(array<string|int, mixed> $configPaths) : mixed
Parameters
- $configPaths : array<string|int, mixed>
Return values
mixed —addMiddleware()
Adds a middleware
public
addMiddleware(string $interface) : mixed
It adds only if it isn't in the middlewares yet
Parameters
- $interface : string
Return values
mixed —finish()
Finishes the application
public
finish(string|int $content) : null
If the $exitOnFinish true (default) calls the exit, otherwise just prints out the content.
Parameters
- $content : string|int
-
Content for the output. If it's an int, it is the return code of the process.
Return values
null —fullInit()
Fully initializes the application
public
fullInit() : mixed
Creates the Config, loads the configs, creates the Logger, calls the init() method
then runs all of the middlewares. If an exception happens, handles it with the handleException() method.
Return values
mixed —fullProcess()
Calls the `process()` method within a try/catch, handles exception with the `handleException()` method
public
fullProcess() : mixed
Return values
mixed —init()
Abstract function for initialize the application
public
abstract init() : mixed
Return values
mixed —process()
Abstract function for processing the application
public
abstract process() : mixed
Return values
mixed —handleException()
Handles the exception
protected
handleException(Exception $e) : mixed
Sends the type, the line, the exception message and the stacktrace to the standard error output.
If the Config or the Logger wasn't initialised throws a MicroException.
Parameters
- $e : Exception
-
The exception
Tags
Return values
mixed —loadConfigs()
Loads all of the configs by the `$configPaths`
protected
loadConfigs() : mixed
Return values
mixed —runMiddlewares()
Runs all of the added middlewares
protected
runMiddlewares() : mixed