Zend Framework  3.0
Public Member Functions | Static Public Member Functions | List of all members
Server Class Reference

"Serve" incoming HTTP requests More...

Public Member Functions

 __construct (callable $callback, ServerRequestInterface $request, ResponseInterface $response)
 Constructor.
 
 __get ($name)
 Allow retrieving the request, response and callback as properties.
 
 setEmitter (Response\EmitterInterface $emitter)
 Set alternate response emitter to use.
 
 listen (callable $finalHandler=null)
 "Listen" to an incoming request
 

Static Public Member Functions

static createServer (callable $callback, array $server, array $query, array $body, array $cookies, array $files)
 Create a Server instance.
 
static createServerFromRequest (callable $callback, ServerRequestInterface $request, ResponseInterface $response=null)
 Create a Server instance from an existing request object.
 

Detailed Description

"Serve" incoming HTTP requests

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

Constructor & Destructor Documentation

__construct ( callable  $callback,
ServerRequestInterface  $request,
ResponseInterface  $response 
)

Constructor.

Given a callback, a request, and a response, we can create a server.

Parameters
callable$callback
ServerRequestInterface$request
ResponseInterface$response

Member Function Documentation

__get (   $name)

Allow retrieving the request, response and callback as properties.

Parameters
string$name
Returns
mixed
Exceptions
OutOfBoundsExceptionfor invalid properties
static 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
static createServerFromRequest ( callable  $callback,
ServerRequestInterface  $request,
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
ServerRequestInterface$request
null | ResponseInterface$response
Returns
static
listen ( callable  $finalHandler = null)

"Listen" to an incoming request

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

Output buffering is enabled prior to invoking the attached callback; any output buffered will be sent prior to any response body content.

Parameters
null | callable$finalHandler
setEmitter ( Response\EmitterInterface  $emitter)

Set alternate response emitter to use.

Parameters
Response\EmitterInterface$emitter