Provides web Request and Response objects for use by web controllers and actions. These are representations of the PHP web environment, not HTTP request and response objects proper.
This library requires PHP 5.3 or later; we recommend using the latest available version of PHP as a matter of principle. It 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 unit tests at the command line, issue
composer install and then
./vendor/bin/phpunit at the package root. This requires Composer to be available as
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(); ?>
Note that if
jit-globals is turned on, merely passing
$GLOBALS will not
work properly. In this case, use
compact() to pass the needed values. For
<?php use Aura\Web\WebFactory; $web_factory = new WebFactory(array( '_ENV' => $_ENV, '_GET' => $_GET, '_POST' => $_POST, '_COOKIE' => $_COOKIE, '_SERVER' => $_SERVER )); $request = $web_factory->newRequest(); $response = $web_factory->newResponse(); ?>
By way of overview, the Request object has these sub-objects ...
... and the Response object has these sub-objects:
Once you have built a Response you can send it with any HTTP mechanism you prefer, including plain PHP.