Hvolschenk\HTTPRequest
A simple functional PHP library to work with the current http request, (*1)
Installation:
php composer.phar require hvolschenk\http-request
Functions:
GET()
Returns the list of query string parameters. Returns an empty array if none are available., (*2)
GET(void): array;
GETKey()
Returns the value of a single key in the list of query string parameters. Returns an empty string if
the key is not available., (*3)
GETKey(string $key): string;
Returns the list of HTTP request headers. Returns an empty array if none are available., (*4)
headers(void): array;
Returns the value of a single key in the list of HTTP request headers. Returns an empty string if
the key is not available., (*5)
headersKey(string $key): string;
POST()
Returns the POST body. Returns an empty array if it is not available., (*6)
POST(void): array;
POSTKey()
Returns the value of a single key in the POST body. Returns an empty string if the key is not
available., (*7)
POSTKey(string $key): string;
Usage example:
<?php
namespace Sample\Name\Space;
use function Hvolschenk\HTTPRequest\{ GETKey, headersKey, POST };
// ...
if (GETKey('canUpdate') === '1' && doUserAuthCheck(headersKey('Authorization'))) {
doUserUpdate(POST());
}