Download the PHP package proteins/response without Composer
On this page you can find all versions of the php package proteins/response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download proteins/response
More information about proteins/response
Files in proteins/response
Package response
Short Description Handles the HTTP Response for the current execution
License MIT
Informations about the package response
Protein | Response
The response module wrap and handles the payload sended to the request agent.
Install
Require the class via :
Appending data to the response
Append a string to the response buffer via the add
method.
Changing the content type
The type
method accepts a MIME type string (or a Response::TYPE_*
constant) for the body content type.
Adding an header to the response
The header($name, $value)
method set an header for being sended to the request agent.
Get all defined headers
Get response body
Set the entire response body
You can set the entire response body by passing a parameter to the body
method.
Set the HTTP response status
You can set the HTTP response status with the status
method.
The error($code, $message='')
method is used to pass errors.
This method triggers the
core.response.error
event.
Force download of response body
You can force download of response body with download
method passing filename as parameter.
Pass a falsy value to disable download.
Download method support also array as parameter with raw string data.
HTTP/2 Server Push
The HTTP/Server Push support is enabled via the push
method.
If you have a list of resource links to be pushed in the next Response::send
you can pass the URI and the resource type as defined in the W3C Preload Draft
If you don't pass resource type as a second parameter the code will be guess from the extension, however is better (faster) to specify the resource type (for the as
parameter of the preload header format).
The current auto-discovered resource types are :
Extensions | Type |
---|---|
js |
script |
css |
style |
woff ,woff2 ,ttf ,eof |
font |
png ,svg ,gif ,jpg |
image |
other | text |
Multiple resources can be passed to a single push
call via an array :
and as the same as the direct call version you can define resource types via array-keys :
All versions of response with dependencies
proteins/event Version ^1.0.0
proteins/filter Version ^1.0.0
proteins/options Version ^1.0.0