Fr3nch13/CakePHP Utilities

Server
in package
implements EventDispatcherInterface uses EventDispatcherTrait

Runs an application invoking all the PSR7 middleware and the registered application.

Table of Contents

Interfaces

EventDispatcherInterface
Objects implementing this interface can emit events.

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.
$app  : HttpApplicationInterface
$runner  : Runner

Methods

__construct()  : mixed
Constructor
dispatchEvent()  : EventInterface
Wrapper for creating and dispatching events.
emit()  : void
Emit the response using the PHP SAPI.
getApp()  : HttpApplicationInterface
Get the current application.
getEventManager()  : EventManagerInterface
Get the application's event manager or the global one.
run()  : ResponseInterface
Run the request/response through the Application and its middleware.
setEventManager()  : $this
Set the application's event manager.
bootstrap()  : void
Application bootstrap wrapper.

Properties

$_eventClass

Default class name for new event objects.

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

Methods

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

run()

Run the request/response through the Application and its middleware.

public run([ServerRequestInterface|null $request = null ][, MiddlewareQueue|null $middlewareQueue = null ]) : ResponseInterface

This will invoke the following methods:

  • App->bootstrap() - Perform any bootstrapping logic for your application here.
  • App->middleware() - Attach any application middleware here.
  • Trigger the 'Server.buildMiddleware' event. You can use this to modify the from event listeners.
  • Run the middleware queue including the application.
Parameters
$request : ServerRequestInterface|null = null

The request to use or null.

$middlewareQueue : MiddlewareQueue|null = null

MiddlewareQueue or null.

Tags
throws
RuntimeException

When the application does not make a response.

Return values
ResponseInterface

setEventManager()

Set the application's event manager.

public setEventManager(EventManagerInterface $eventManager) : $this

If the application does not support events, an exception will be raised.

Parameters
$eventManager : EventManagerInterface

The event manager to set.

Tags
throws
InvalidArgumentException
Return values
$this

bootstrap()

Application bootstrap wrapper.

protected bootstrap() : void

Calls the application's bootstrap() hook. After the application the plugins are bootstrapped.


        
On this page

Search results