App class
Framework\MVC\App
Class App.
Defined in libraries/mvc/src/App.php
Properties #
- $services
- Array with keys with names of services and their values have arrays where the keys are the names of the instances and the values are the objects.
- $isRunning
- Tells if the App is running.
- $config
- The Config instance.
- $isCli
- Tells if the request is by command line. Updating directly makes it possible to run tests simulating HTTP or CLI.
- $debugCollector
- The App collector instance that is set when in debug mode.
- $defaultServerVars
- Variables set in the $_SERVER super-global in command-line requests.
$services
Array with keys with names of services and their values have arrays where the keys are the names of the instances and the values are the objects.
$isRunning
Tells if the App is running.
$config
The Config instance.
$isCli
Tells if the request is by command line. Updating directly makes it possible to run tests simulating HTTP or CLI.
$debugCollector
The App collector instance that is set when in debug mode.
$defaultServerVars
Variables set in the $_SERVER super-global in command-line requests.
Methods #
- __construct()
- Initialize the App.
- addDebugData()
- Add services data to the debug collector.
- antiCsrf()
- Get a antiCsrf service.
- autoloader()
- Get a autoloader service.
- cache()
- Get a cache service.
- config()
- Get the Config instance.
- console()
- Get a console service.
- database()
- Get a database service.
- debugger()
- Get a debugger service.
- exceptionHandler()
- Get a exceptionHandler service.
- getService()
- Get a service.
- isCli()
- Tell if it is a command-line request.
- isDebugging()
- Tell if the App is in debug mode.
- language()
- Get a language service.
- locator()
- Get a locator service.
- logger()
- Get a logger service.
- mailer()
- Get a mailer service.
- migrator()
- Get a migrator service.
- removeService()
- Remove services.
- request()
- Get a request service.
- response()
- Get a response service.
- router()
- Get a router service.
- run()
- Detects if the request is via command-line and runs as a CLI request, otherwise runs as HTTP.
- runCli()
- Run the App on CLI requests.
- runHttp()
- Run the App on HTTP requests.
- session()
- Get a session service.
- setIsCli()
- Set if it is a CLI request. Used for testing.
- setService()
- Set a service.
- validation()
- Get a validation service.
- view()
- Get a view service.
- addCommand()
- Detects if the file has a command and adds it to the console.
- debugEnd()
- Ends the debugging of the App and prints the debugbar if there is no download file, if the request is not via AJAX and the Content-Type is text/html.
- debugStart()
- Start debugging the App.
- loadAutoloader()
- Make sure to load the autoloader service if its default config is set.
- loadConfigs()
- Load service configs catching exceptions.
- loadExceptionHandler()
- Make sure to load the exceptionHandler service if its default config is set.
- negotiateLanguage()
- Negotiates the language either via the command line or over HTTP.
- prepareToRun()
- Prepare the App to run via CLI or HTTP.
- requireRouterFiles()
- Load files that set the routes.
- setAntiCsrf()
- Set a antiCsrf service.
- setAutoloader()
- Set a autoloader service.
- setCache()
- Set a cache service.
- setConsole()
- Set a console service.
- setDatabase()
- Set a database service.
- setDebugger()
- Set a debugger service.
- setExceptionHandler()
- Set a exceptionHandler service.
- setLanguage()
- Set a language service.
- setLocator()
- Set a locator service.
- setLogger()
- Set a logger service.
- setMailer()
- Set a mailer service.
- setMigrator()
- Set a migrator service.
- setRequest()
- Set a request service.
- setResponse()
- Set a response service.
- setRouter()
- Set a router service.
- setServerVars()
- Overrides variables to be set in the $_SERVER super-global when the request is made via the command line.
- setSession()
- Set a session service.
- setValidation()
- Set a validation service.
- setView()
- Set a view service.
__construct()
Initialize the App.
- \Framework\Config\Config|array|string|null $config - The config
- bool $debug - Set true to enable debug mode. False to disable.
addDebugData()
Add services data to the debug collector.
- string $service - Service name
- string $instance - Service instance name
- float $start - Microtime right before setting up the service
- float $end - Microtime right after setting up the service
antiCsrf()
Get a antiCsrf service.
- string $instance - The antiCsrf instance name
autoloader()
Get a autoloader service.
- string $instance - The autoloader instance name
cache()
Get a cache service.
- string $instance - The cache instance name
config()
Get the Config instance.
console()
Get a console service.
- string $instance - The console instance name
database()
Get a database service.
- string $instance - The database instance name
debugger()
Get a debugger service.
- string $instance - The debugger instance name
exceptionHandler()
Get a exceptionHandler service.
- string $instance - The exceptionHandler instance name
getService()
Get a service.
- string $name - Service name
- string $instance - Service instance name
isCli()
Tell if it is a command-line request.
isDebugging()
Tell if the App is in debug mode.
language()
Get a language service.
- string $instance - The language instance name
locator()
Get a locator service.
- string $instance - The locator instance name
logger()
Get a logger service.
- string $instance - The logger instance name
mailer()
Get a mailer service.
- string $instance - The mailer instance name
migrator()
Get a migrator service.
- string $instance - The migrator instance name
removeService()
Remove services.
- string $name - Service name
- ?string $instance - Service instance name or null to remove all instances
request()
Get a request service.
- string $instance - The request instance name
response()
Get a response service.
- string $instance - The response instance name
router()
Get a router service.
- string $instance - The router instance name
run()
Detects if the request is via command-line and runs as a CLI request, otherwise runs as HTTP.
runCli()
Run the App on CLI requests.
runHttp()
Run the App on HTTP requests.
session()
Get a session service.
- string $instance - The session instance name
setIsCli()
Set if it is a CLI request. Used for testing.
- bool $is
setService()
Set a service.
- string $name - Service name
- object $service - Service object
- string $instance - Service instance name
validation()
Get a validation service.
- string $instance - The validation instance name
view()
Get a view service.
- string $instance - The view instance name
addCommand()
Detects if the file has a command and adds it to the console.
- string $file - The file to get the command class
- \Framework\CLI\Console $console - The console to add the class
- \Framework\Autoload\Locator $locator - The locator to get the class name in the file
debugEnd()
Ends the debugging of the App and prints the debugbar if there is no download file, if the request is not via AJAX and the Content-Type is text/html.
debugStart()
Start debugging the App.
loadAutoloader()
Make sure to load the autoloader service if its default config is set.
loadConfigs()
Load service configs catching exceptions.
- string $name - The service name
loadExceptionHandler()
Make sure to load the exceptionHandler service if its default config is set.
negotiateLanguage()
Negotiates the language either via the command line or over HTTP.
- \Framework\Language\Language $language - The current Language instance
- string $requestInstance - The name of the Request instance to be used
prepareToRun()
Prepare the App to run via CLI or HTTP.
requireRouterFiles()
Load files that set the routes.
- array $files - The path of the router files
- \Framework\Routing\Router $router
setAntiCsrf()
Set a antiCsrf service.
- string $instance - The antiCsrf instance name
setAutoloader()
Set a autoloader service.
- string $instance - The autoloader instance name
setCache()
Set a cache service.
- string $instance - The cache instance name
setConsole()
Set a console service.
- string $instance - The console instance name
setDatabase()
Set a database service.
- string $instance - The database instance name
- ?\Framework\Database\Debug\DatabaseCollector $collector
setDebugger()
Set a debugger service.
- string $instance - The debugger instance name
setExceptionHandler()
Set a exceptionHandler service.
- string $instance - The exceptionHandler instance name
setLanguage()
Set a language service.
- string $instance - The language instance name
setLocator()
Set a locator service.
- string $instance - The locator instance name
setLogger()
Set a logger service.
- string $instance - The logger instance name
setMailer()
Set a mailer service.
- string $instance - The mailer instance name
setMigrator()
Set a migrator service.
- string $instance - The migrator instance name
setRequest()
Set a request service.
- string $instance - The request instance name
setResponse()
Set a response service.
- string $instance - The response instance name
setRouter()
Set a router service.
- string $instance - The router instance name
- ?array $config - The router instance configs or null
setServerVars()
Overrides variables to be set in the $_SERVER super-global when the request is made via the command line.
- array $vars
setSession()
Set a session service.
- string $instance - The session instance name
setValidation()
Set a validation service.
- string $instance - The validation instance name
setView()
Set a view service.
- string $instance - The view instance name