\Cake\HttpServer

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

Summary

Methods
Properties
Constants
eventManager()
getEventManager()
setEventManager()
dispatchEvent()
__construct()
run()
emit()
getApp()
setRunner()
No public properties found
No constants found
bootstrap()
$_eventManager
$_eventClass
$app
$runner
N/A
No private methods found
No private properties found
N/A

Properties

$_eventClass

$_eventClass : string

Default class name for new event objects.

Type

string

Methods

eventManager()

eventManager(\Cake\Event\EventManager|null  $events = null) : \Cake\Event\EventManager|$this

Get/set the application's event manager.

If the application does not support events and this method is used as a setter, an exception will be raised.

Parameters

\Cake\Event\EventManager|null $events

The event manager to set.

Returns

\Cake\Event\EventManager|$this

getEventManager()

getEventManager() : \Cake\Event\EventManager

Get the application's event manager or the global one.

Returns

\Cake\Event\EventManager

setEventManager()

setEventManager(\Cake\Event\EventManager  $events) : $this

Get/set the application's event manager.

If the application does not support events and this method is used as a setter, an exception will be raised.

Parameters

\Cake\Event\EventManager $events

The event manager to set.

Returns

$this

dispatchEvent()

dispatchEvent(string  $name, array|null  $data = null, object|null  $subject = null) : \Cake\Event\Event

Wrapper for creating and dispatching events.

Returns a dispatched event.

Parameters

string $name

Name of the event.

array|null $data

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

object|null $subject

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

Returns

\Cake\Event\Event

run()

run(\Psr\Http\Message\ServerRequestInterface|null  $request = null, \Psr\Http\Message\ResponseInterface|null  $response = null) : \Psr\Http\Message\ResponseInterface

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

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

\Psr\Http\Message\ServerRequestInterface|null $request

The request to use or null.

\Psr\Http\Message\ResponseInterface|null $response

The response to use or null.

Throws

\RuntimeException

When the application does not make a response.

Returns

\Psr\Http\Message\ResponseInterface

setRunner()

setRunner(\Cake\Http\Runner  $runner) : $this

Set the runner

Parameters

\Cake\Http\Runner $runner

The runner to use.

Returns

$this

bootstrap()

bootstrap() : void

Application bootstrap wrapper.

Calls bootstrap() and events() if application implements EventApplicationInterface. After the application is bootstrapped and events are attached, plugins are bootstrapped and have their events attached.