Download the PHP package bayfrontmedia/php-http-response without Composer
On this page you can find all versions of the php package bayfrontmedia/php-http-response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bayfrontmedia/php-http-response
More information about bayfrontmedia/php-http-response
Files in bayfrontmedia/php-http-response
Package php-http-response
Short Description Easily send HTTP responses.
License MIT
Homepage https://github.com/bayfrontmedia/php-http-response
Informations about the package php-http-response
PHP HTTP response
Easily send HTTP responses.
- License
- Author
- Requirements
- Installation
- Usage
License
This project is open source and available under the MIT License.
Author
Requirements
- PHP
^8.0
- JSON PHP extension
Installation
Usage
- reset
- setStatusCode
- getStatusCode
- removeHeaders
- setHeaders
- getHeaders
- setBody
- getBody
- send
- sendJson
- redirect
reset
Description:
Resets all headers (including status code) and body.
Parameters:
- None
Returns:
- (self)
Example:
setStatusCode
Description:
Sets status code to be sent with response.
Parameters:
$status
(int)
Returns:
- (self)
Throws:
Bayfront\HttpResponse\InvalidStatusCodeException
Example:
getStatusCode
Description:
Returns the status code and associated phrase to be sent with response.
Parameters:
- None
Returns:
- (array)
Example:
removeHeaders
Description:
Sets header values to be removed with the response.
Parameters:
$headers
(array)
Returns:
- (self)
Example:
setHeaders
Description:
Sets header values to be sent with the response.
Parameters:
$headers
(array)
Returns:
- (self)
Example:
getHeaders
Description:
Returns array of headers to be sent with the response.
Parameters:
- None
Returns:
- (array)
Example:
setBody
Description:
Sets body to be sent with the response.
Parameters:
$body
(string)
Returns:
- (self)
Example:
getBody
Description:
Returns body to be sent with the response.
Parameters:
- None
Returns:
- (string)
Example:
send
Description:
Sends response.
Parameters:
- None
Returns:
- (void)
Example:
sendJson
Description:
Sets Content-Type as application/json
, and converts the given array to the JSON encoded body.
Parameters:
$array
(array)
Returns:
- (void)
Example:
redirect
Description:
Redirects to a given URL using a given status code.
Parameters:
$url
(string)$status = 302
(int): HTTP status code to return
Returns:
- (void)
Throws:
Bayfront\HttpResponse\InvalidStatusCodeException
Example:
All versions of php-http-response with dependencies
ext-json Version *