Class BaseApplication
Base class for application classes.
The application class is responsible for bootstrapping the application, and ensuring that middleware is attached. It is also invoked as the last piece of middleware, and delegates request/response handling to the correct controller.
Properties summary
- $_eventClass protected
string
Default class name for new event objects.
- $_eventManager protected
\Cake\Event\EventManagerInterface|\Cake\Event\EventManager
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
- $configDir protected
string
- $plugins protected
\Cake\Core\PluginCollection
Plugin Collection
Method Summary
Method Detail
__construct() public
__construct(mixed $configDir, \Cake\Event\EventManagerInterface $eventManager)
Constructor
Parameters
-
string
$configDir The directory the bootstrap configuration is held in.
-
\Cake\Event\EventManagerInterface
$eventManager optional Application event manager instance.
__invoke() public
__invoke(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, mixed $next)
Invoke the application.
- Convert the PSR response into CakePHP equivalents.
- Create the controller that will handle this request.
- Invoke the controller.
Parameters
-
\Psr\Http\Message\ServerRequestInterface
$request The request
-
\Psr\Http\Message\ResponseInterface
$response The response
-
callable
$next The next middleware
Returns
\Psr\Http\Message\ResponseInterface
addOptionalPlugin() public
addOptionalPlugin(mixed $name, array $config)
Add an optional plugin
If it isn't available, ignore it.
Parameters
-
string|\Cake\Core\PluginInterface
$name The plugin name or plugin object.
-
array
$config optional The configuration data for the plugin if using a string for $name
Returns
$this
addPlugin() public
addPlugin(mixed $name, array $config)
Add a plugin to the loaded plugin set.
If the named plugin does not exist, or does not define a Plugin class, an instance of Cake\Core\BasePlugin
will be used. This generated class will have all plugin hooks enabled.
Parameters
-
string|\Cake\Core\PluginInterface
$name The plugin name or plugin object.
-
array
$config optional The configuration data for the plugin if using a string for $name
Returns
$this
bootstrap() public
bootstrap()
Load all the application configuration and bootstrap logic.
Override this method to add additional bootstrap logic for your application.
console() public
console(mixed $commands)
Define the console commands for an application.
By default all commands in CakePHP, plugins and the application will be loaded using conventions based names.
Parameters
-
\Cake\Console\CommandCollection
$commands The CommandCollection to add commands into.
Returns
\Cake\Console\CommandCollection
The updated collection.
dispatchEvent() public
dispatchEvent(mixed $name, mixed $data, mixed $subject)
Wrapper for creating and dispatching events.
Returns a dispatched event.
Parameters
-
string
$name Name of the event.
-
array|null
$data optional Any value you wish to be transported with this event to it can be read by listeners.
-
object|null
$subject optional The object that this event applies to ($this by default).
Returns
\Cake\Event\Event
eventManager() public
eventManager(\Cake\Event\EventManager $eventManager)
Returns the Cake\Event\EventManager manager instance for this object.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Parameters
-
\Cake\Event\EventManager|null
$eventManager optional the eventManager to set
Returns
\Cake\Event\EventManager
getDispatcher() protected
getDispatcher()
Get the ActionDispatcher.
Returns
\Cake\Http\ActionDispatcher
getEventManager() public
getEventManager()
Returns the Cake\Event\EventManager manager instance for this object.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Returns
\Cake\Event\EventManager
getPlugins() public
getPlugins()
Get the plugin collection in use.
Returns
\Cake\Core\PluginCollection
makePlugin() protected
makePlugin(mixed $name, array $config)
Create a plugin instance from a classname and configuration
Parameters
-
string
$name The plugin classname
-
array
$config Configuration options for the plugin
Returns
\Cake\Core\PluginInterface
middleware() abstract public
middleware(mixed $middleware)
Parameters
-
\Cake\Http\MiddlewareQueue
$middleware The middleware queue to set in your App Class
Returns
\Cake\Http\MiddlewareQueue
pluginBootstrap() public
pluginBootstrap()
Run bootstrap logic for loaded plugins.
pluginConsole() public
pluginConsole(mixed $commands)
Run console hooks for plugins
Parameters
-
\Cake\Console\CommandCollection
$commands The CommandCollection to use.
Returns
\Cake\Console\CommandCollection
pluginMiddleware() public
pluginMiddleware(mixed $middleware)
Run middleware hooks for plugins
Parameters
-
\Cake\Http\MiddlewareQueue
$middleware The MiddlewareQueue to use.
Returns
\Cake\Http\MiddlewareQueue
pluginRoutes() public
pluginRoutes(mixed $routes)
Run routes hooks for loaded plugins
Parameters
-
\Cake\Routing\RouteBuilder
$routes The route builder to use.
Returns
\Cake\Routing\RouteBuilder
routes() public
routes(mixed $routes)
Define the routes for an application.
Use the provided RouteBuilder to define an application's routing.
Parameters
-
\Cake\Routing\RouteBuilder
$routes A route builder to add routes into.
setEventManager() public
setEventManager(\Cake\Event\EventManager $eventManager)
Returns the Cake\Event\EventManager manager instance for this object.
You can use this instance to register any new listeners or callbacks to the object events, or create your own events and trigger them at will.
Parameters
-
\Cake\Event\EventManager
$eventManager the eventManager to set
Returns
$this
Property Detail
$_eventClass protected
Default class name for new event objects.
Type
string
$_eventManager protected
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
Type
\Cake\Event\EventManagerInterface|\Cake\Event\EventManager
$configDir protected
Type
string
$plugins protected
Plugin Collection
Type
\Cake\Core\PluginCollection
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.9/class-Cake.Http.BaseApplication.html