Class Request
An HTTP request.
<?php use ICanBoogie\HTTP\Request; # Creating the main request $request = Request::from($_SERVER); # Creating a request from scratch, with the current environment. $request = Request::from([ 'uri' => '/path/to/my/page.html?page=2', 'user_agent' => 'Mozilla' 'is_get' => true, 'is_xhr' => true, 'is_local' => true ], $_SERVER);
- ICanBoogie\HTTP\Request implements ArrayAccess, IteratorAggregate uses ICanBoogie\Accessor\AccessorTrait (not available)
See: http://en.wikipedia.org/wiki/Uniform_resource_locator
Located at Request.php
Methods summary
public static
from( array $properties
= null, array $env
= [] )
: ICanBoogie\HTTP\Request
A request can be created from the $_SERVER
super global array. In that case $_SERVER
is
used as environment the request is created with the following properties:
protected static
from_server( void )
: ICanBoogie\HTTP\Request
Creates an instance from the $_SERVER
array.
protected static
from_uri( string $uri
, array $env
)
: ICanBoogie\HTTP\Request
Creates an instance from an URI.
protected static
from_properties( array $properties
, array $env
)
: ICanBoogie\HTTP\Request
Creates an instance from an array of properties.
protected
__construct( array $properties
, array $env
= [] )
Initialize the properties ICanBoogie\HTTP\Request::$env
, ICanBoogie\HTTP\Request::$headers
and ICanBoogie\HTTP\Request::$context
.
public
send( string|null $method
= null, array $params
= null )
: ICanBoogie\HTTP\Response
Dispatch the request.
protected
dispatch( void )
: ICanBoogie\HTTP\Response
Dispatches the request using the ICanBoogie\HTTP\Request::dispatch()
helper.
public
with( array $properties
)
: ICanBoogie\HTTP\Request
Returns a new instance with the specified changed properties.
protected
adapt( string $method
, array $params
= null )
: ICanBoogie\HTTP\Request
Adapts the request to the specified method and params.
public
__call( $method
, $arguments
)
: mixed
Overrides the method to provide a virtual method for each request method.
public
offsetExists( string $param
)
: boolean
Checks if the specified param exists in the request's params.
protected
get_cache_control( void )
: ICanBoogie\HTTP\Headers\CacheControl
Returns the Cache-Control
header.
protected
get_path( void )
: string
Returns the path of the request, that is the REQUEST_URI
without the query string.
protected
get_normalized_path( void )
: string
Returns the $path property normalized using the \ICanBoogie\normalize_url_path() function.
protected
lazy_get_params( void )
: array
Returns the union of the ICanBoogie\HTTP\Request::$path_params
, ICanBoogie\HTTP\Request::$request_params
and
ICanBoogie\HTTP\Request::$query_params
properties.
Magic methods summary
Constants summary
Properties summary
public static
$methods
: array
[ self::METHOD_CONNECT, self::METHOD_DELETE, self::METHOD_GET, self::METHOD_HEAD, self::METHOD_OPTIONS, self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH, self::METHOD_TRACE ]