Request
in package
implements
RequestInterface
Uses
Container
HTTP Request Provider
PHP Mini Framework
This class borrows heavily from the Symfony2 Framework and is part of the Symfony package. See Symfony\Component\HttpFoundation\Request (https://github.com/symfony/symfony)
Tags
Interfaces, Classes, Traits and Enums
- RequestInterface
- PHP Mini Framework
Table of Contents
- $baseUrl : string|null
- $content : mixed
- $contentType : string|null
- $cookies : AttributeBag|null
- $currentUrl : string|null
- $domain : string|null
- $files : AttributeBag|null
- $headers : AttributeBag|null
- $host : string|null
- $ip : string|null
- $method : string|null
- $protocol : string|null
- $psr : ServerRequestInterface|null
- $query : AttributeBag|null
- $request : AttributeBag|null
- $scheme : string|null
- $server : AttributeBag|null
- $session : SessionBag|null
- $uri : string|null
- $cookieOptions : array<string|int, mixed>
- $sessionOptions : array<string|int, mixed>
- $singletons : array<string|int, mixed>
- addSingleton() : self
- Add singleton
- baseUrl() : string
- content() : mixed
- contentType() : string
- cookie() : AttributeBag
- currentUrl() : string
- domain() : string
- file() : AttributeBag
- fromGlobal() : self
- Create request object from Globals
- fromPsr() : self
- Create request object from PSR7 Server request
- fromUrl() : self
- Create request object using custom URL
- getContent() : string|resource
- Returns the request body content.
- getSingleton() : self
- Get singleton
- header() : AttributeBag
- host() : string
- initialize() : self
- Sets the parameters for this request.
- ip() : mixed
- method() : string
- query() : AttributeBag
- request() : AttributeBag
- scheme() : string
- segments() : array<string|int, mixed>
- Get all of the segments for the request path.
- server() : AttributeBag
- session() : SessionBag
- setCookies() : self
- Set the value of cookies
- setFiles() : self
- Set the value of files
- setHeaders() : self
- Set the value of headers
- setQuery() : self
- Set the value of query
- setRequest() : self
- Set the value of request
- setServer() : self
- Set the value of server
- setSession() : self
- Set the value of session
- toPsr() : ServerRequestInterface
- Get PSR7 Server request
- uri() : string
- version() : string
- withUri() : self
- Change request's url. Clone request with new url
- __construct() : mixed
- Constructor.
- getHeadersFromServer() : array<string|int, mixed>
- Get request headers from Server Variables
- getIpAddress() : string
- Get Ip
- isHttps() : bool
- Check if https enabled
- validateIpAddress() : bool
- Ensures an ip address is both a valid IP and does not fall within a private network range.
- getServerPotocol() : string
- Get server protocol or http version
Properties
$baseUrl
protected
string|null
$baseUrl
= NULL
Tags
$content
protected
mixed
$content
= NUll
Tags
$contentType
protected
string|null
$contentType
= NULL
Tags
$cookies
protected
AttributeBag|null
$cookies
= null
Tags
$currentUrl
protected
string|null
$currentUrl
= NULL
Tags
$domain
protected
string|null
$domain
= NULL
Tags
$files
protected
AttributeBag|null
$files
= null
Tags
$headers
protected
AttributeBag|null
$headers
= null
Tags
$host
protected
string|null
$host
= NULL
Tags
$ip
protected
string|null
$ip
= NULL
Tags
$method
protected
string|null
$method
= NULL
Tags
$protocol
protected
string|null
$protocol
= NULL
Tags
$psr
protected
ServerRequestInterface|null
$psr
= NUll
Tags
$query
protected
AttributeBag|null
$query
= null
Tags
$request
protected
AttributeBag|null
$request
= null
Tags
$scheme
protected
string|null
$scheme
= NULL
Tags
$server
protected
AttributeBag|null
$server
= null
Tags
$session
protected
SessionBag|null
$session
= null
Tags
$uri
protected
string|null
$uri
= NULL
Tags
$cookieOptions
private
array<string|int, mixed>
$cookieOptions
= []
Tags
$sessionOptions
private
array<string|int, mixed>
$sessionOptions
= []
Tags
$singletons
private
array<string|int, mixed>
$singletons
= []
Tags
Methods
addSingleton()
Add singleton
public
addSingleton(string $className, object|null &$object) : self
Parameters
- $className : string
- $object : object|null
Tags
Return values
self —baseUrl()
public
baseUrl() : string
Return values
string —content()
public
content() : mixed
Return values
mixed —contentType()
public
contentType() : string
Return values
string —cookie()
public
cookie() : AttributeBag
Tags
Return values
AttributeBag —currentUrl()
public
currentUrl() : string
Return values
string —domain()
public
domain() : string
Return values
string —file()
public
file() : AttributeBag
Tags
Return values
AttributeBag —fromGlobal()
Create request object from Globals
public
static fromGlobal() : self
Tags
Return values
self —fromPsr()
Create request object from PSR7 Server request
public
static fromPsr(ServerRequestInterface $psr) : self
Parameters
- $psr : ServerRequestInterface
Tags
Return values
self —fromUrl()
Create request object using custom URL
public
static fromUrl(string $url[, string $method = HttpMethod::GET ]) : self
Parameters
- $url : string
- $method : string = HttpMethod::GET
Tags
Return values
self —getContent()
Returns the request body content.
public
getContent([bool $asResource = false ]) : string|resource
Parameters
- $asResource : bool = false
-
- If true, a resource will be returned
Tags
Return values
string|resource —- The request body content or a resource to read the body stream.
getSingleton()
Get singleton
public
getSingleton(string $className[, object $default = null ]) : self
Parameters
- $className : string
- $default : object = null
Tags
Return values
self —header()
public
header() : AttributeBag
Tags
Return values
AttributeBag —host()
public
host() : string
Return values
string —initialize()
Sets the parameters for this request.
public
initialize([AttributeBag $query = NULL ][, AttributeBag $request = NULL ][, AttributeBag $cookies = NULL ][, SessionBag $session = NULL ][, AttributeBag $files = NULL ][, AttributeBag $server = NULL ][, AttributeBag $headers = NULL ][, string $content = null ]) : self
This method also re-initializes all properties.
Parameters
- $query : AttributeBag = NULL
-
- The GET parameters
- $request : AttributeBag = NULL
-
- The POST parameters
- $cookies : AttributeBag = NULL
-
- The COOKIE parameters
- $session : SessionBag = NULL
-
- The SESSION parameters
- $files : AttributeBag = NULL
-
- The FILES parameters
- $server : AttributeBag = NULL
-
- The SERVER parameters
- $headers : AttributeBag = NULL
-
- The headers
- $content : string = null
-
- The raw body data
Tags
Return values
self —ip()
public
ip() : mixed
Return values
mixed —method()
public
method() : string
Return values
string —query()
public
query() : AttributeBag
Return values
AttributeBag —request()
public
request() : AttributeBag
Return values
AttributeBag —scheme()
public
scheme() : string
Return values
string —segments()
Get all of the segments for the request path.
public
segments() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —server()
public
server() : AttributeBag
Return values
AttributeBag —session()
public
session() : SessionBag
Return values
SessionBag —setCookies()
Set the value of cookies
public
setCookies(AttributeBag $cookies) : self
Parameters
- $cookies : AttributeBag
Tags
Return values
self —setFiles()
Set the value of files
public
setFiles(AttributeBag $files) : self
Parameters
- $files : AttributeBag
Tags
Return values
self —setHeaders()
Set the value of headers
public
setHeaders(AttributeBag $headers) : self
Parameters
- $headers : AttributeBag
Tags
Return values
self —setQuery()
Set the value of query
public
setQuery(AttributeBag $query) : self
Parameters
- $query : AttributeBag
Tags
Return values
self —setRequest()
Set the value of request
public
setRequest(AttributeBag $request) : self
Parameters
- $request : AttributeBag
Tags
Return values
self —setServer()
Set the value of server
public
setServer(AttributeBag $server) : self
Parameters
- $server : AttributeBag
Tags
Return values
self —setSession()
Set the value of session
public
setSession(SessionBag $session) : self
Parameters
- $session : SessionBag
Tags
Return values
self —toPsr()
Get PSR7 Server request
public
toPsr() : ServerRequestInterface
Tags
Return values
ServerRequestInterface —uri()
public
uri() : string
Return values
string —version()
public
version() : string
Tags
Return values
string —withUri()
Change request's url. Clone request with new url
public
withUri(UriInterface $uri) : self
Parameters
- $uri : UriInterface
Tags
Return values
self —__construct()
Constructor.
protected
__construct() : mixed
Tags
Return values
mixed —getHeadersFromServer()
Get request headers from Server Variables
protected
getHeadersFromServer(array<string|int, mixed> $server) : array<string|int, mixed>
Parameters
- $server : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getIpAddress()
Get Ip
protected
getIpAddress() : string
Tags
Return values
string —isHttps()
Check if https enabled
protected
isHttps() : bool
Tags
Return values
bool —validateIpAddress()
Ensures an ip address is both a valid IP and does not fall within a private network range.
protected
validateIpAddress( $ip) : bool
Parameters
Tags
Return values
bool —getServerPotocol()
Get server protocol or http version
private
getServerPotocol() : string