Download the PHP package anax/request without Composer
On this page you can find all versions of the php package anax/request. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package request
Short Description Anax Request module, details on the request.
License MIT
Homepage https://dbwebb.se/anax
Informations about the package request
Anax Request
Anax Request module for wrapping all request related information.
The module essentially wraps access to $_GET, $_POST, $_SERVER
, information send through the HTTP body and calculates url details (current, site, base, route path) from the request uri.
The module provides a framework unified way to access these global variables and it provides a way to inject a certain setup when using the module for unit testing.
Table of content
- Class, interface, trait
- Exceptions
- Configuration file
- DI service
- General usage within the Anax framework
- Access as framework service
- Create and init an object
- Extract url and route parts
- Get and set
$_SERVER
- Get and set
$_GET
- Get and set
$_POST
- Get and set request body
Class, interface, trait
The following classes, interfaces and traits exists.
Class, interface, trait | Description |
---|---|
Anax\Request\Request |
Wrapper class for request details and related. |
Exceptions
Module specific exceptions are thrown through Anax\Request\Exception
.
Configuration file
There is no configuration file for this module.
DI service
The module is created as a framework service within $di
. You can see the details in the configuration file config/di/request.php
.
It can look like this.
- The object is created as a shared resource.
- The init-method reads information from the environment to find out the url of the request.
The service is lazy loaded and not created until it is used.
General usage within the Anax framework
The request service is a mandatory service within the Anax framework and it is the first service used when handling a request.
Here is the general flow for receiving a request, mapping it to a route and returning a response. This is found in the frontcontroller htdocs/index.php
of an Anax installation.
The request is used to get the request method and the route path, these are used by the router service to find a callback for the route. Each callback can then return a response which is sent through the response service.
Access as framework service
You can access the module as a framework service.
Create and init an object
This is how the object can be created. This is usually done within the framework as a sevice in $di
.
Extract url and route parts
When the object is initiated you can extract url and route parts from it. This is based on the current url.
Get and set $_SERVER
You can get and set values in the PHP global variable $_SERVER
.
You are reading and setting values in a copy of $_SERVER
, so you are not actually editing the global variable, just the internal representation within the class.
Get and set $_GET
You can get and set values in the PHP global variable $_GET
.
You are reading and setting values in a copy of $_GET
, so you are not actually editing the global variable, just the internal representation within the class.
Get and set $_POST
You can get and set values in the PHP global variable $_POST
.
You are reading and setting values in a copy of $_POST
, so you are not actually editing the global variable, just the internal representation within the class.
Get and set request body
You can get and set the value in the HTTP request body. Sometimes the HTTP request body is used to send parameters to an route.
You are setting values in a copy of the actual body, so you are not actually editing it, just the internal representation within the class.
License
This software carries a MIT license. See LICENSE.txt for details.