Provides web Request and Response objects for use by web controllers. These are representations of the PHP web environment, not HTTP request and response objects proper.
This library requires PHP 5.3 or later, and has no userland dependencies.
It is installable and autoloadable via Composer as aura/web.
Alternatively, download a release or clone this repository, then require or include its autoload.php file.
To run the PHPUnit tests at the command line, go to the tests directory and issue
First, instantiate a WebFactory object, then use it to create Request and Response objects.
<?php use Aura\Web\WebFactory; $web_factory = new WebFactory($GLOBALS); $request = $web_factory->newRequest(); $response = $web_factory->newResponse(); ?>
By way of overview, the Request object has these sub-objects ...
- $request->cookies for $_COOKIES
- $request->env for $_ENV
- $request->files for $_FILES
- $request->post for $_POST
- $request->query for $_GET
- $request->server for $_SERVER
- $request->client for the client making the request
- $request->content for the raw body of the request
- $request->headers for the request headers
- $request->method for the request method
- $request->accept for content negotiation
- $request->params for path-info parameters
- $request->url for the request URL
... and the Response object has these sub-objects:
- $response->status for the status code, status phrase, and HTTP version
- $response->headers for non-cookie headers
- $response->cookies for cookie headers
- $response->content for describing the response content, and for convenience methods related to content type, charset, disposition, and filename
- $response->cache for convenience methods related to cache headers
- $response->redirect for convenience methods related to Location and Status
Once you have built a Response you can send it with any HTTP mechanism you prefer, including plain PHP.