Fr3nch13/CakePHP Utilities

BaseApplication
in package
implements ConsoleApplicationInterface, ContainerApplicationInterface, HttpApplicationInterface, PluginApplicationInterface, RoutingApplicationInterface uses EventDispatcherTrait

AbstractYes

Base class for full-stack applications

This class serves as a base class for applications that are using CakePHP as a full stack framework. If you are only using the Http or Console libraries you should implement the relevant interfaces directly.

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.

Table of Contents

Interfaces

ConsoleApplicationInterface
An interface defining the methods that the console runner depend on.
ContainerApplicationInterface
Interface for applications that configure and use a dependency injection container.
HttpApplicationInterface
An interface defining the methods that the http server depend on.
PluginApplicationInterface
Interface for Applications that leverage plugins & events.
RoutingApplicationInterface
Interface for applications that use routing.

Properties

$_eventClass  : string
Default class name for new event objects.
$_eventManager  : EventManagerInterface|null
Instance of the Cake\Event\EventManager this object is using to dispatch inner events.
$configDir  : string
$container  : ContainerInterface|null
Container
$controllerFactory  : ControllerFactoryInterface|null
Controller factory
$plugins  : PluginCollection
Plugin Collection

Methods

__construct()  : mixed
Constructor
addOptionalPlugin()  : $this
Add an optional plugin
addPlugin()  : $this
Add a plugin to the loaded plugin set.
bootstrap()  : void
Load all the application configuration and bootstrap logic.
console()  : CommandCollection
Define the console commands for an application.
dispatchEvent()  : EventInterface
Wrapper for creating and dispatching events.
getContainer()  : ContainerInterface
Get the dependency injection container for the application.
getEventManager()  : EventManagerInterface
Returns the Cake\Event\EventManager manager instance for this object.
getPlugins()  : PluginCollection
Get the plugin collection in use.
handle()  : ResponseInterface
Invoke the application.
middleware()  : MiddlewareQueue
Define the HTTP middleware layers for an application.
pluginBootstrap()  : void
Run bootstrap logic for loaded plugins.
pluginConsole()  : CommandCollection
Run console hooks for plugins
pluginMiddleware()  : MiddlewareQueue
Run middleware hooks for plugins
pluginRoutes()  : RouteBuilder
Run routes hooks for loaded plugins
routes()  : void
Define the routes for an application.
services()  : void
Register application container services.
setEventManager()  : $this
Returns the Cake\Event\EventManagerInterface instance for this object.
buildContainer()  : ContainerInterface
Build the service container

Properties

$_eventClass

Default class name for new event objects.

protected string $_eventClass = \Cake\Event\Event::class

$configDir

protected string $configDir

Contains the path of the config directory

Methods

addOptionalPlugin()

Add an optional plugin

public addOptionalPlugin(PluginInterface|string $name[, array<string, mixed> $config = [] ]) : $this

If it isn't available, ignore it.

Parameters
$name : PluginInterface|string

The plugin name or plugin object.

$config : array<string, mixed> = []

The configuration data for the plugin if using a string for $name

Return values
$this

addPlugin()

Add a plugin to the loaded plugin set.

public addPlugin(mixed $name[, array<string|int, mixed> $config = [] ]) : $this
Parameters
$name : mixed

The plugin name or plugin object.

$config : array<string|int, mixed> = []

The configuration data for the plugin if using a string for $name

Tags
inheritDoc
Return values
$this

bootstrap()

Load all the application configuration and bootstrap logic.

public bootstrap() : void
Tags
inheritDoc

dispatchEvent()

Wrapper for creating and dispatching events.

public dispatchEvent(string $name[, array<string|int, mixed>|null $data = null ][, object|null $subject = null ]) : EventInterface

Returns a dispatched event.

Parameters
$name : string

Name of the event.

$data : array<string|int, mixed>|null = null

Any value you wish to be transported with this event to it can be read by listeners.

$subject : object|null = null

The object that this event applies to ($this by default).

Return values
EventInterface

getEventManager()

Returns the Cake\Event\EventManager manager instance for this object.

public getEventManager() : EventManagerInterface

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.

Return values
EventManagerInterface

pluginBootstrap()

Run bootstrap logic for loaded plugins.

public pluginBootstrap() : void
Tags
inheritDoc

routes()

Define the routes for an application.

public routes(RouteBuilder $routes) : void

By default, this will load config/routes.php for ease of use and backwards compatibility.

Parameters
$routes : RouteBuilder

A route builder to add routes into.

setEventManager()

Returns the Cake\Event\EventManagerInterface instance for this object.

public setEventManager(EventManagerInterface $eventManager) : $this

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
$eventManager : EventManagerInterface

the eventManager to set

Return values
$this

        
On this page

Search results