Request
in package
implements
RequestInterface
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
- $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>
- 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.
- 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
- uri() : 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
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
$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
Methods
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.
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 —uri()
public
uri() : string
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>