Pop
extends Application
in package
This is the main class for the Popcorn Micro-Framework.
Tags
Table of Contents
Properties
- $config : mixed
- Application config
- $autoloader : mixed
- Autoloader
- $config : mixed
- Application config
- $events : Manager|null
- Event manager
- $modules : Manager|null
- Module manager
- $name : string|null
- Name
- $router : Router|null
- Application router
- $routes : array<string|int, mixed>
- Routes array
- $services : Locator|null
- Service locator
- $version : string|null
- Version
Methods
- __call() : void
- Magic method to check for a custom method
- __construct() : mixed
- Constructor
- __get() : mixed
- Get a pre-designated value from the application object
- __isset() : bool
- Determine if a pre-designated value in the application object exists
- __set() : void
- Set a pre-designated value in the application object
- __unset() : void
- Unset a pre-designated value in the application object
- addConfigValue() : AbstractApplication
- Add new value to config
- addCustomMethod() : Pop
- Add a custom method
- addCustomMethods() : Pop
- Add custom methods
- addRoute() : static
- Add a route
- addRoutes() : static
- Add routes
- addToAll() : Pop
- Add to all methods
- any() : Pop
- Add to any and all methods (alias method to addToAll)
- autoloader() : mixed
- Get the autoloader object
- bootstrap() : static
- Bootstrap the application, creating the required objects if they haven't been created yet and registering with the autoloader, adding routes, services and events
- config() : mixed
- Access application config
- connect() : Pop
- Add a CONNECT route
- delete() : Pop
- Add a DELETE route
- deleteConfigValue() : AbstractApplication
- Replace existing value in config
- env() : mixed
- Get environment value
- environment() : string|null|bool
- Get application environment
- events() : Manager
- Get the event manager
- get() : Pop
- Add a GET route
- getName() : string
- Get name
- getRoute() : mixed
- Method to get a route by method
- getRoutes() : array<string|int, mixed>
- Method to get all routes
- getService() : mixed
- Get a service
- getVersion() : string
- Get version
- hasCustomMethod() : bool
- Has a custom method
- hasName() : bool
- Determine if the name is set
- hasRoute() : bool
- Method to determine if the application has a route
- hasVersion() : bool
- Determine if version has been set
- head() : Pop
- Add a HEAD route
- init() : static
- Initialize the application
- isAllowed() : bool
- Determine if the route is allowed on for the method
- isDev() : bool
- Check if application environment is dev
- isDown() : bool
- Check if application is in maintenance mode
- isLocal() : bool
- Check if application environment is local
- isProduction() : bool
- Check if application environment is production
- isRegistered() : bool
- Determine whether a module is registered with the application object
- isStaging() : bool
- Check if application environment is staging
- isTesting() : bool
- Check if application environment is testing
- isUp() : bool
- Check if application is in not maintenance mode
- load() : AbstractApplication
- Optional method that can be used to load custom operations/configurations for an application to run
- mergeConfig() : AbstractApplication
- Merge new or altered config values with the existing config values
- module() : ModuleInterface|null
- Access a module object
- modules() : Manager
- Access all application module configs
- name() : string|null
- Get application name (alias method)
- off() : static
- Detach an event. Default hook-points are:
- offsetExists() : bool
- Determine if a pre-designated value in the application object exists
- offsetGet() : mixed
- Get a pre-designated value from the application object
- offsetSet() : void
- Set a pre-designated value in the application object
- offsetUnset() : void
- Unset a pre-designated value in the application object
- on() : static
- Attach an event. Default hook-points are:
- options() : Pop
- Add an OPTIONS route
- patch() : Pop
- Add a PATCH route
- post() : Pop
- Add a POST route
- put() : Pop
- Add a PUT route
- register() : static
- Register a module with the module manager object
- registerAutoloader() : static
- Register the autoloader object with the application
- registerConfig() : AbstractApplication
- Register a new configuration with the application
- registerEvents() : static
- Register a new event manager object with the application
- registerModules() : static
- Register a new module manager object with the application
- registerRouter() : static
- Register a new router object with the application
- registerServices() : static
- Register a new service locator object with the application
- removeService() : static
- Remove a service
- router() : Router
- Access the application router
- run() : void
- Run the application.
- services() : Locator
- Get the service locator
- setName() : static
- Set name
- setRoute() : Pop
- Add a route
- setRoutes() : Pop
- Add multiple routes
- setService() : static
- Set a service
- setVersion() : static
- Set version
- trace() : Pop
- Add a TRACE route
- trigger() : static
- Trigger an event
- unregister() : static
- Unregister a module with the module manager object
- updateConfigValue() : AbstractApplication
- Update existing value in config
- url() : string|null
- Get application URL
Properties
$config
Application config
public
mixed
$config
mixed
$autoloader
Autoloader
protected
mixed
$autoloader
= null
$config
Application config
protected
mixed
$config
= null
$events
Event manager
protected
Manager|null
$events
= null
$modules
Module manager
protected
Manager|null
$modules
= null
$name
Name
protected
string|null
$name
= null
$router
Application router
protected
Router|null
$router
= null
$routes
Routes array
protected
array<string|int, mixed>
$routes
= ['get' => [], 'head' => [], 'post' => [], 'put' => [], 'delete' => [], 'trace' => [], 'options' => [], 'connect' => [], 'patch' => []]
$services
Service locator
protected
Locator|null
$services
= null
$version
Version
protected
string|null
$version
= null
Methods
__call()
Magic method to check for a custom method
public
__call(string $methodName, array<string|int, mixed> $arguments) : void
Parameters
- $methodName : string
- $arguments : array<string|int, mixed>
Tags
__construct()
Constructor
public
__construct() : mixed
Instantiate an application object
Optional parameters are a service locator instance, a router instance, an event manager instance or a configuration object or array
Tags
__get()
Get a pre-designated value from the application object
public
__get(string $name) : mixed
Parameters
- $name : string
__isset()
Determine if a pre-designated value in the application object exists
public
__isset(string $name) : bool
Parameters
- $name : string
Return values
bool__set()
Set a pre-designated value in the application object
public
__set(string $name, mixed $value) : void
Parameters
- $name : string
- $value : mixed
Tags
__unset()
Unset a pre-designated value in the application object
public
__unset(string $name) : void
Parameters
- $name : string
addConfigValue()
Add new value to config
public
addConfigValue(string $name, string $value) : AbstractApplication
Parameters
- $name : string
- $value : string
Return values
AbstractApplicationaddCustomMethod()
Add a custom method
public
addCustomMethod(string $customMethod) : Pop
Parameters
- $customMethod : string
Return values
PopaddCustomMethods()
Add custom methods
public
addCustomMethods(array<string|int, mixed> $customMethods) : Pop
Parameters
- $customMethods : array<string|int, mixed>
Return values
PopaddRoute()
Add a route
public
addRoute(string $route, mixed $controller) : static
Parameters
- $route : string
- $controller : mixed
Return values
staticaddRoutes()
Add routes
public
addRoutes(array<string|int, mixed> $routes) : static
Parameters
- $routes : array<string|int, mixed>
Return values
staticaddToAll()
Add to all methods
public
addToAll(string $route, mixed $controller) : Pop
Parameters
- $route : string
- $controller : mixed
Tags
Return values
Popany()
Add to any and all methods (alias method to addToAll)
public
any(string $route, mixed $controller) : Pop
Parameters
- $route : string
- $controller : mixed
Return values
Popautoloader()
Get the autoloader object
public
autoloader() : mixed
bootstrap()
Bootstrap the application, creating the required objects if they haven't been created yet and registering with the autoloader, adding routes, services and events
public
bootstrap([mixed $autoloader = null ]) : static
Parameters
- $autoloader : mixed = null
Tags
Return values
staticconfig()
Access application config
public
config() : mixed
connect()
Add a CONNECT route
public
connect(string $route, mixed $controller) : Pop
Parameters
- $route : string
- $controller : mixed
Tags
Return values
Popdelete()
Add a DELETE route
public
delete(string $route, mixed $controller) : Pop
Parameters
- $route : string
- $controller : mixed
Tags
Return values
PopdeleteConfigValue()
Replace existing value in config
public
deleteConfigValue(string $name) : AbstractApplication
Parameters
- $name : string
Return values
AbstractApplicationenv()
Get environment value
public
env(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
environment()
Get application environment
public
environment([mixed $env = null ]) : string|null|bool
Parameters
- $env : mixed = null
Return values
string|null|boolevents()
Get the event manager
public
events() : Manager
Return values
Managerget()
Add a GET route
public
get(string $route, mixed $controller) : Pop
Parameters
- $route : string
- $controller : mixed
Tags
Return values
PopgetName()
Get name
public
getName() : string
Return values
stringgetRoute()
Method to get a route by method
public
getRoute(string $method, string $route) : mixed
Parameters
- $method : string
- $route : string
getRoutes()
Method to get all routes
public
getRoutes([string|null $method = null ]) : array<string|int, mixed>
Parameters
- $method : string|null = null
Tags
Return values
array<string|int, mixed>getService()
Get a service
public
getService(string $name) : mixed
Parameters
- $name : string
Tags
getVersion()
Get version
public
getVersion() : string
Return values
stringhasCustomMethod()
Has a custom method
public
hasCustomMethod(string $customMethod) : bool
Parameters
- $customMethod : string
Return values
boolhasName()
Determine if the name is set
public
hasName() : bool
Return values
boolhasRoute()
Method to determine if the application has a route
public
hasRoute(string $method, string $route) : bool
Parameters
- $method : string
- $route : string
Return values
boolhasVersion()
Determine if version has been set
public
hasVersion() : bool
Return values
boolhead()
Add a HEAD route
public
head(string $route, mixed $controller) : Pop
Parameters
- $route : string
- $controller : mixed
Tags
Return values
Popinit()
Initialize the application
public
init() : static
Return values
staticisAllowed()
Determine if the route is allowed on for the method
public
isAllowed([string|null $route = null ]) : bool
Parameters
- $route : string|null = null
Return values
boolisDev()
Check if application environment is dev
public
isDev() : bool
Return values
boolisDown()
Check if application is in maintenance mode
public
isDown() : bool
Return values
boolisLocal()
Check if application environment is local
public
isLocal() : bool
Return values
boolisProduction()
Check if application environment is production
public
isProduction() : bool
Return values
boolisRegistered()
Determine whether a module is registered with the application object
public
isRegistered(string $name) : bool
Parameters
- $name : string
Return values
boolisStaging()
Check if application environment is staging
public
isStaging() : bool
Return values
boolisTesting()
Check if application environment is testing
public
isTesting() : bool
Return values
boolisUp()
Check if application is in not maintenance mode
public
isUp() : bool
Return values
boolload()
Optional method that can be used to load custom operations/configurations for an application to run
public
load() : AbstractApplication
Return values
AbstractApplicationmergeConfig()
Merge new or altered config values with the existing config values
public
mergeConfig(mixed $config[, bool $preserve = false ]) : AbstractApplication
Parameters
- $config : mixed
- $preserve : bool = false
Tags
Return values
AbstractApplicationmodule()
Access a module object
public
module(string $name) : ModuleInterface|null
Parameters
- $name : string
Return values
ModuleInterface|nullmodules()
Access all application module configs
public
modules() : Manager
Return values
Managername()
Get application name (alias method)
public
name() : string|null
Return values
string|nulloff()
Detach an event. Default hook-points are:
public
off(string $name, mixed $action) : static
app.init app.route.pre app.dispatch.pre app.dispatch.post app.error
Parameters
- $name : string
- $action : mixed
Return values
staticoffsetExists()
Determine if a pre-designated value in the application object exists
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
booloffsetGet()
Get a pre-designated value from the application object
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
offsetSet()
Set a pre-designated value in the application object
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
- $value : mixed
Tags
offsetUnset()
Unset a pre-designated value in the application object
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
on()
Attach an event. Default hook-points are:
public
on(string $name, mixed $action[, int $priority = 0 ]) : static
app.init app.route.pre app.dispatch.pre app.dispatch.post app.error
Parameters
- $name : string
- $action : mixed
- $priority : int = 0
Return values
staticoptions()
Add an OPTIONS route
public
options(string $route, mixed $controller) : Pop
Parameters
- $route : string
- $controller : mixed
Tags
Return values
Poppatch()
Add a PATCH route
public
patch(string $route, mixed $controller) : Pop
Parameters
- $route : string
- $controller : mixed
Tags
Return values
Poppost()
Add a POST route
public
post(string $route, mixed $controller) : Pop
Parameters
- $route : string
- $controller : mixed
Tags
Return values
Popput()
Add a PUT route
public
put(string $route, mixed $controller) : Pop
Parameters
- $route : string
- $controller : mixed
Tags
Return values
Popregister()
Register a module with the module manager object
public
register(mixed $module[, string|null $name = null ]) : static
Parameters
- $module : mixed
- $name : string|null = null
Tags
Return values
staticregisterAutoloader()
Register the autoloader object with the application
public
registerAutoloader(mixed $autoloader) : static
Parameters
- $autoloader : mixed
Tags
Return values
staticregisterConfig()
Register a new configuration with the application
public
registerConfig(mixed $config) : AbstractApplication
Parameters
- $config : mixed
Tags
Return values
AbstractApplicationregisterEvents()
Register a new event manager object with the application
public
registerEvents(Manager $events) : static
Parameters
- $events : Manager
Return values
staticregisterModules()
Register a new module manager object with the application
public
registerModules(Manager $modules) : static
Parameters
- $modules : Manager
Return values
staticregisterRouter()
Register a new router object with the application
public
registerRouter(Router $router) : static
Parameters
- $router : Router
Return values
staticregisterServices()
Register a new service locator object with the application
public
registerServices(Locator $services) : static
Parameters
- $services : Locator
Return values
staticremoveService()
Remove a service
public
removeService(string $name) : static
Parameters
- $name : string
Return values
staticrouter()
Access the application router
public
router() : Router
Return values
Routerrun()
Run the application.
public
run([bool $exit = true ][, string|null $forceRoute = null ]) : void
Parameters
- $exit : bool = true
- $forceRoute : string|null = null
Tags
services()
Get the service locator
public
services() : Locator
Return values
LocatorsetName()
Set name
public
setName(string $name) : static
Parameters
- $name : string
Return values
staticsetRoute()
Add a route
public
setRoute(string $method, string $route, mixed $controller) : Pop
Parameters
- $method : string
- $route : string
- $controller : mixed
Tags
Return values
PopsetRoutes()
Add multiple routes
public
setRoutes(array<string|int, mixed>|string $methods, string $route, mixed $controller) : Pop
Parameters
- $methods : array<string|int, mixed>|string
- $route : string
- $controller : mixed
Tags
Return values
PopsetService()
Set a service
public
setService(string $name, mixed $service) : static
Parameters
- $name : string
- $service : mixed
Tags
Return values
staticsetVersion()
Set version
public
setVersion(string $version) : static
Parameters
- $version : string
Return values
statictrace()
Add a TRACE route
public
trace(string $route, mixed $controller) : Pop
Parameters
- $route : string
- $controller : mixed
Tags
Return values
Poptrigger()
Trigger an event
public
trigger(string $name[, array<string|int, mixed> $args = [] ]) : static
Parameters
- $name : string
- $args : array<string|int, mixed> = []
Return values
staticunregister()
Unregister a module with the module manager object
public
unregister(string $name) : static
Parameters
- $name : string
Return values
staticupdateConfigValue()
Update existing value in config
public
updateConfigValue(string $name, string $value) : AbstractApplication
Parameters
- $name : string
- $value : string
Return values
AbstractApplicationurl()
Get application URL
public
url() : string|null