PHP Class PPI\Framework\App

This class sets various app settings, and allows you to override classes used in the bootup process.
Author: Paul Dragoonis ([email protected])
Author: Vítor Brandão ([email protected])
Inheritance: implements PPI\Framework\AppInterface
Afficher le fichier Open project: ppi/framework Class Usage Examples

Protected Properties

Свойство Type Description
$booted boolean
$configManager PPI\Framework\Config\ConfigManager Configuration loader.
$debug boolean
$environment string Application environment: "dev|development" vs "prod|production".
$errorReportingLevel
$logger Psr\Log\LoggerInterface
$matchedRoute null | array
$moduleManager Zend\ModuleManager\ModuleManager The Module Manager.
$name string
$resolver PPI\Framework\Module\Controller\ControllerResolver
$rootDir null | string Path to the application root dir aka the "app" directory.
$serviceManager PPI\Framework\ServiceManager\ServiceManager Service Manager.
$startTime float Unix timestamp with microseconds.

Méthodes publiques

Méthode Description
__clone ( )
__construct ( array $options = [] ) App constructor.
boot ( ) Run the boot process, load our modules and their dependencies.
dispatch ( PPI\Framework\Http\Request $request, PPI\Framework\Http\Response $response ) : PPI\Framework\Http\Response Decide on a route to use and dispatch our module's controller action.
getCacheDir ( ) : string Gets the cache directory.
getCharset ( ) : string Gets the charset of the application.
getConfig ( ) : array | object Returns the application configuration.
getConfigManager ( ) : PPI\Framework\Config\ConfigManager Returns a ConfigManager instance.
getContainer ( ) : null | PPI\Framework\ServiceManager\ServiceManager
getEnvironment ( ) : string Get the environment mode the application is in.
getLogDir ( ) : string Gets the log directory.
getModuleManager ( ) : Zend\ModuleManager\ModuleManager Returns the Module Manager.
getModules ( ) : array Get an array of the loaded modules.
getName ( ) : string Gets the name of the application.
getRootDir ( ) : string Gets the application root dir.
getServiceManager ( ) : PPI\Framework\ServiceManager\ServiceManager Get the service manager.
getStartTime ( ) : integer Gets the request start time (not available if debug is disabled).
getVersion ( ) : string Gets the version of the application.
isDebug ( ) : boolean Checks if debug mode is enabled.
isEnvironment ( $env ) : boolean
loadConfig ( $resource, null $type = null ) : App Loads a configuration file or PHP array.
locateResource ( string $name, string $dir = null, boolean $first = true ) : string | array
run ( PPI\Framework\Http\Request $request = null, PPI\Framework\Http\Response $response = null ) : PPI\Framework\Http\Response Run the application and send the response.
serialize ( ) : string
setSymfonyKernel ( Symfony\Component\HttpKernel\KernelInterface $kernel )
unserialize ( $data )

Méthodes protégées

Méthode Description
buildServiceManager ( ) : PPI\Framework\ServiceManager\ServiceManager Creates and initializes a ServiceManager instance.
getAppParameters ( ) : array Returns the application parameters.
getEnvParameters ( ) : array Gets the environment parameters.
handleRouting ( PPI\Framework\Http\Request $request ) : array Perform the matching of a route and return a set of routing parameters if a valid one is found.
log ( mixed $level, string $message, array $context = [] ) Logs with an arbitrary level.

Method Details

__clone() public méthode

public __clone ( )

__construct() public méthode

App constructor.
public __construct ( array $options = [] )
$options array

boot() public méthode

This method is automatically called by dispatch(), but you can use it to build all services when not handling a request.
public boot ( )

buildServiceManager() protected méthode

Creates and initializes a ServiceManager instance.
protected buildServiceManager ( ) : PPI\Framework\ServiceManager\ServiceManager
Résultat PPI\Framework\ServiceManager\ServiceManager The compiled service manager

dispatch() public méthode

Decide on a route to use and dispatch our module's controller action.
public dispatch ( PPI\Framework\Http\Request $request, PPI\Framework\Http\Response $response ) : PPI\Framework\Http\Response
$request PPI\Framework\Http\Request
$response PPI\Framework\Http\Response
Résultat PPI\Framework\Http\Response

getAppParameters() protected méthode

Returns the application parameters.
protected getAppParameters ( ) : array
Résultat array An array of application parameters

getCacheDir() public méthode

Gets the cache directory.
public getCacheDir ( ) : string
Résultat string The cache directory

getCharset() public méthode

Gets the charset of the application.
public getCharset ( ) : string
Résultat string The charset

getConfig() public méthode

Returns the application configuration.
public getConfig ( ) : array | object
Résultat array | object

getConfigManager() public méthode

Returns a ConfigManager instance.
public getConfigManager ( ) : PPI\Framework\Config\ConfigManager
Résultat PPI\Framework\Config\ConfigManager

getContainer() public méthode

public getContainer ( ) : null | PPI\Framework\ServiceManager\ServiceManager
Résultat null | PPI\Framework\ServiceManager\ServiceManager

getEnvParameters() protected méthode

Only the parameters starting with "PPI__" are considered.
protected getEnvParameters ( ) : array
Résultat array An array of parameters

getEnvironment() public méthode

Get the environment mode the application is in.
public getEnvironment ( ) : string
Résultat string The current environment

getLogDir() public méthode

Gets the log directory.
public getLogDir ( ) : string
Résultat string The log directory

getModuleManager() public méthode

Returns the Module Manager.
public getModuleManager ( ) : Zend\ModuleManager\ModuleManager
Résultat Zend\ModuleManager\ModuleManager

getModules() public méthode

Get an array of the loaded modules.
public getModules ( ) : array
Résultat array An array of Module objects, keyed by module name

getName() public méthode

Gets the name of the application.
public getName ( ) : string
Résultat string The application name

getRootDir() public méthode

Gets the application root dir.
public getRootDir ( ) : string
Résultat string The application root dir

getServiceManager() public méthode

Get the service manager.
public getServiceManager ( ) : PPI\Framework\ServiceManager\ServiceManager
Résultat PPI\Framework\ServiceManager\ServiceManager

getStartTime() public méthode

Gets the request start time (not available if debug is disabled).
public getStartTime ( ) : integer
Résultat integer The request start timestamp

getVersion() public méthode

Gets the version of the application.
public getVersion ( ) : string
Résultat string The application version

handleRouting() protected méthode

Otherwise exceptions get thrown.
protected handleRouting ( PPI\Framework\Http\Request $request ) : array
$request PPI\Framework\Http\Request
Résultat array

isDebug() public méthode

Checks if debug mode is enabled.
public isDebug ( ) : boolean
Résultat boolean true if debug mode is enabled, false otherwise

isEnvironment() public méthode

public isEnvironment ( $env ) : boolean
$env
Résultat boolean

loadConfig() public méthode

Loads a configuration file or PHP array.
public loadConfig ( $resource, null $type = null ) : App
$resource
$type null
Résultat App The current instance

locateResource() public méthode

See also: PPI\Framework\Module\ModuleManager::locateResource()
public locateResource ( string $name, string $dir = null, boolean $first = true ) : string | array
$name string A resource name to locate
$dir string A directory where to look for the resource first
$first boolean Whether to return the first path or paths for all matching bundles
Résultat string | array The absolute path of the resource or an array if $first is false

log() protected méthode

Logs with an arbitrary level.
protected log ( mixed $level, string $message, array $context = [] )
$level mixed
$message string
$context array

run() public méthode

Run the application and send the response.
public run ( PPI\Framework\Http\Request $request = null, PPI\Framework\Http\Response $response = null ) : PPI\Framework\Http\Response
$request PPI\Framework\Http\Request
$response PPI\Framework\Http\Response
Résultat PPI\Framework\Http\Response

serialize() public méthode

public serialize ( ) : string
Résultat string

setSymfonyKernel() public méthode

public setSymfonyKernel ( Symfony\Component\HttpKernel\KernelInterface $kernel )
$kernel Symfony\Component\HttpKernel\KernelInterface

unserialize() public méthode

public unserialize ( $data )

Property Details

$booted protected_oe property

protected bool $booted
Résultat boolean

$configManager protected_oe property

Configuration loader.
protected ConfigManager,PPI\Framework\Config $configManager
Résultat PPI\Framework\Config\ConfigManager

$debug protected_oe property

protected bool $debug
Résultat boolean

$environment protected_oe property

Application environment: "dev|development" vs "prod|production".
protected string $environment
Résultat string

$errorReportingLevel protected_oe property

protected $errorReportingLevel

$logger protected_oe property

protected LoggerInterface,Psr\Log $logger
Résultat Psr\Log\LoggerInterface

$matchedRoute protected_oe property

protected null|array $matchedRoute
Résultat null | array

$moduleManager protected_oe property

The Module Manager.
protected ModuleManager,Zend\ModuleManager $moduleManager
Résultat Zend\ModuleManager\ModuleManager

$name protected_oe property

protected string $name
Résultat string

$resolver protected_oe property

protected ControllerResolver,PPI\Framework\Module\Controller $resolver
Résultat PPI\Framework\Module\Controller\ControllerResolver

$rootDir protected_oe property

Path to the application root dir aka the "app" directory.
protected null|string $rootDir
Résultat null | string

$serviceManager protected_oe property

Service Manager.
protected ServiceManager,PPI\Framework\ServiceManager $serviceManager
Résultat PPI\Framework\ServiceManager\ServiceManager

$startTime protected_oe property

Unix timestamp with microseconds.
protected float $startTime
Résultat float