\Zend\DiactorosServer

"Serve" incoming HTTP requests

Given a callback, takes an incoming request, dispatches it to the callback, and then sends a response.

Summary

Methods
Properties
Constants
__construct()
__get()
setEmitter()
createServer()
createServerFromRequest()
listen()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
getEmitter()
$callback
$emitter
$request
$response
N/A

Properties

$callback

$callback : callable

Type

callable

Methods

__get()

__get(string  $name) : mixed

Allow retrieving the request, response and callback as properties

Parameters

string $name

Throws

\OutOfBoundsException

for invalid properties

Returns

mixed

createServer()

createServer(callable  $callback, array  $server, array  $query, array  $body, array  $cookies, array  $files) : static

Create a Server instance

Creates a server instance from the callback and the following PHP environmental values:

  • server; typically this will be the $_SERVER superglobal
  • query; typically this will be the $_GET superglobal
  • body; typically this will be the $_POST superglobal
  • cookies; typically this will be the $_COOKIE superglobal
  • files; typically this will be the $_FILES superglobal

Parameters

callable $callback
array $server
array $query
array $body
array $cookies
array $files

Returns

static

createServerFromRequest()

createServerFromRequest(callable  $callback, \Psr\Http\Message\ServerRequestInterface  $request, null|\Psr\Http\Message\ResponseInterface  $response = null) : static

Create a Server instance from an existing request object

Provided a callback, an existing request object, and optionally an existing response object, create and return the Server instance.

If no Response object is provided, one will be created.

Parameters

callable $callback
\Psr\Http\Message\ServerRequestInterface $request
null|\Psr\Http\Message\ResponseInterface $response

Returns

static

listen()

listen(null|callable  $finalHandler = null) 

"Listen" to an incoming request

If provided a $finalHandler, that callable will be used for incomplete requests.

Parameters

null|callable $finalHandler

getEmitter()

getEmitter() : \Zend\Diactoros\Response\EmitterInterface

Retrieve the current response emitter.

If none has been registered, lazy-loads a Response\SapiEmitter.

Returns

\Zend\Diactoros\Response\EmitterInterface