W3cubDocs

/CakePHP 3.4

Class Server

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

Cake\Http\Server uses Cake\Event\EventDispatcherTrait
Namespace: Cake\Http
Location: Http/Server.php

Properties summary

Inherited Properties

Method Summary

  • __construct() public
    Constructor
  • emit() public
    Emit the response using the PHP SAPI.
  • getApp() public
    Get the current application.
  • run() public
    Run the request/response through the Application and its middleware.
  • setApp() public
    Set the application.
  • setRunner() public
    Set the runner

Method Detail

__construct()source public

__construct( Cake\Http\BaseApplication $app )

Constructor

Parameters

Cake\Http\BaseApplication $app
The application to use.

emit()source public

emit( Psr\Http\Message\ResponseInterface $response , Zend\Diactoros\Response\EmitterInterface $emitter null )

Emit the response using the PHP SAPI.

Parameters

Psr\Http\Message\ResponseInterface $response
The response to emit
Zend\Diactoros\Response\EmitterInterface $emitter optional null

The emitter to use. When null, a SAPI Stream Emitter will be used.

getApp()source public

getApp( )

Get the current application.

Returns

Cake\Http\BaseApplication
The application that will be run.

run()source public

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

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 $request optional null
The request to use or null.
Psr\Http\Message\ResponseInterface $response optional null
The response to use or null.

Returns

Psr\Http\Message\ResponseInterface

Throws

RuntimeException
When the application does not make a response.

setApp()source public

setApp( Cake\Http\BaseApplication $app )

Set the application.

Parameters

Cake\Http\BaseApplication $app
The application to set.

Returns


$this

setRunner()source public

setRunner( Cake\Http\Runner $runner )

Set the runner

Parameters

Cake\Http\Runner $runner
The runner to use.

Returns


$this

Methods used from Cake\Event\EventDispatcherTrait

dispatchEvent()source public

dispatchEvent( string $name , array|null $data null , object|null $subject null )

Wrapper for creating and dispatching events.

Returns a dispatched event.

Parameters

string $name
Name of the event.
array|null $data optional null

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

object|null $subject optional null

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

Returns

Cake\Event\Event

eventManager()source public

eventManager( Cake\Event\EventManager $eventManager null )

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 optional null
the eventManager to set

Returns

Cake\Event\EventManager

Properties detail

$runnersource

protected Cake\Http\Runner

© 2005–2017 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.4/class-Cake.Http.Server.html