Download the PHP package bayfrontmedia/php-http-request without Composer
On this page you can find all versions of the php package bayfrontmedia/php-http-request. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-http-request
PHP HTTP request
Easily handle data from incoming HTTP requests.
- License
- Author
- Requirements
- Installation
- Usage
License
This project is open source and available under the MIT License.
Author
Requirements
- PHP
^8.0
Installation
Usage
Request methods
- validateMethod
- getMethod
- isConnect
- isDelete
- isGet
- isHead
- isOptions
- isPatch
- isPost
- isPut
- isTrace
Data types
- getFile
- hasFile
- getQuery
- hasQuery
- getPost
- hasPost
- getServer
- hasServer
- getCookie
- hasCookie
- getHeader
- hasHeader
- getBody
- hasBody
Specific values
- getUserAgent
- getReferer
- getIp
- isCli
- isJson
- wantsJson
- isHttps
- getRequest
- getUrl
validateMethod
Description:
Returns valid request method with a fallback to GET
.
Valid request methods include:
CONNECT
DELETE
GET
HEAD
OPTIONS
PATCH
POST
PUT
TRACE
Parameters:
$method
(string)
Returns:
- (string)
Example:
getMethod
Description:
Returns current request method.
Parameters:
- None
Returns:
- (string)
Example:
isConnect
Description:
Is current request method CONNECT
.
Parameters:
- None
Returns:
- (bool)
Example:
isDelete
Description:
Is current request method DELETE
.
Parameters:
- None
Returns:
- (bool)
Example:
isGet
Description:
Is current request method GET
.
Parameters:
- None
Returns:
- (bool)
Example:
isHead
Description:
Is current request method HEAD
.
Parameters:
- None
Returns:
- (bool)
Example:
isOptions
Description:
Is current request method OPTIONS
.
Parameters:
- None
Returns:
- (bool)
Example:
isPatch
Description:
Is current request method PATCH
.
Parameters:
- None
Returns:
- (bool)
Example:
isPost
Description:
Is current request method POST
.
Parameters:
- None
Returns:
- (bool)
Example:
isPut
Description:
Is current request method PUT
.
Parameters:
- None
Returns:
- (bool)
Example:
isTrace
Description:
Is current request method TRACE
.
Parameters:
- None
Returns:
- (bool)
Example:
getFile
Description:
Returns value of single $_FILES
array key in dot notation or entire array, with optional default value.
Parameters:
$key = NULL
(string|null)$default = NULL
(mixed): Default value to return if array key is not found
Returns:
- (mixed)
Example:
hasFile
Description:
Checks if $_FILES
array key exists in dot notation.
Parameters:
$key
(string)
Returns:
- (bool)
Example:
getQuery
Description:
Returns value of single $_GET
array key in dot notation or entire array, with optional default value.
Parameters:
$key = NULL
(string|null)$default = NULL
(mixed): Default value to return if array key is not found
Returns:
- (mixed)
Example:
hasQuery
Description:
Checks if $_GET
array key exists in dot notation.
Parameters:
$key
(string)
Returns:
- (bool)
Example:
getPost
Description:
Returns value of single $_POST
array key in dot notation or entire array, with optional default value.
Parameters:
$key = NULL
(string|null)$default = NULL
(mixed): Default value to return if array key is not found
Returns:
- (mixed)
Example:
hasPost
Description:
Checks if $_POST
array key exists in dot notation.
Parameters:
$key
(string)
Returns:
- (bool)
Example:
getServer
Description:
Returns value of single $_SERVER
array key in dot notation or entire array, with optional default value.
Parameters:
$key = NULL
(string|null)$default = NULL
(mixed): Default value to return if array key is not found
Returns:
- (mixed)
Example:
hasServer
Description:
Checks if $_SERVER
array key exists in dot notation.
Parameters:
$key
(string)
Returns:
- (bool)
Example:
getCookie
Description:
Returns value of single $_COOKIE
array key in dot notation or entire array, with optional default value.
Parameters:
$key = NULL
(string|null)$default = NULL
(mixed): Default value to return if array key is not found
Returns:
- (mixed)
Example:
hasCookie
Description:
Checks if $_COOKIE
array key exists in dot notation.
Parameters:
$key
(string)
Returns:
- (bool)
Example:
getHeader
Description:
Returns value of single header array key in dot notation or entire array, with optional default value.
Parameters:
$key = NULL
(string|null)$default = NULL
(mixed): Default value to return if array key is not found
Returns:
- (mixed)
Example:
hasHeader
Description:
Checks if header array key exists in dot notation.
Parameters:
$key
(string)
Returns:
- (bool)
Example:
getBody
Description:
Returns content body of a request.
Parameters:
- None
Returns:
- (string)
Example:
hasBody
Description:
Checks if content body of a request exists.
Parameters:
- None
Returns:
- (bool)
Example:
getUserAgent
Description:
Returns client's user agent.
Parameters:
- None
Returns:
- (mixed): string|null
Example:
getReferer
Description:
Returns client's referring URL.
Parameters:
- None
Returns:
- (mixed): string|null
Example:
getIp
Description:
Returns the most probable IP of client with optional default value.
Parameters:
$default = ''
(string): Default IP address to return if none detected
Returns:
- (string)
Example:
isCli
Description:
Is the request originating from the command line.
Parameters:
- None
Returns:
- (bool)
Example:
isJson
Description:
Is the Content-Type
header for this request JSON.
Parameters:
- None
Returns:
- (bool)
Example:
wantsJson
Description:
Does the Accept
header for this request expect JSON.
Parameters:
- None
Returns:
- (bool)
Example:
isHttps
Description:
Is connection HTTPS.
Parameters:
- None
Returns:
- (bool)
Example:
getRequest
Description:
Returns array containing details of the client's request, or string of a specific part of the request.
Parameters:
$part = ''
(string): Which part of the request to return. Leaving this blank will return the entire array.
Valid $part
values include any of the PART_*
constants:
Requst::PART_METHOD
Request::PART_PROTOCOL
Request::PART_HOST
Request::PART_PATH
Request::PART_QUERY
Request::PART_QUERY_STRING
Request::PART_URL
Request::PART_FULL_URL
Returns:
- (mixed): array|string
Example:
getUrl
Description:
Returns current URL.
Parameters:
$include_query = false
(bool): Include the query string, if existing
Returns:
- (string)
Example: