Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • CacheControlHeader
  • CallableDispatcher
  • ContentDispositionHeader
  • ContentTypeHeader
  • DateHeader
  • Dispatcher
  • File
  • FileList
  • Header
  • HeaderParameter
  • Headers
  • Helpers
  • RedirectResponse
  • Request
  • Response
  • WeightedDispatcher

Interfaces

  • IDispatcher

Exceptions

  • ForceRedirect
  • HTTPError
  • MethodNotSupported
  • NotFound
  • ServiceUnavailable
  • StatusCodeNotValid

Functions

  • dispatch
  • get_dispatcher
  • get_initial_request

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(array(

    'uri' => '/path/to/my/page.html?page=2',
    'user_agent' => 'Mozilla'
    'is_get' => true,
    'is_xhr' => true,
    'is_local' => true

), array($_SERVER));
ICanBoogie\Object implements ICanBoogie\ToArrayRecursive uses ICanBoogie\ToArrayRecursiveTrait, ICanBoogie\PrototypeTrait
Extended by ICanBoogie\HTTP\Request implements ArrayAccess, IteratorAggregate
Namespace: ICanBoogie\HTTP
See: http://en.wikipedia.org/wiki/Uniform_resource_locator
Located at vendor/icanboogie/http/lib/request.php

Methods summary

public static ICanBoogie\HTTP\Request
# get_current_request( )

Returns the current request.

Returns the current request.

Returns

ICanBoogie\HTTP\Request
protected
# get_files( )
public static ICanBoogie\HTTP\Request
# from( array $properties = null, array $construct_args = array(), string $class_name = null )

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:

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:

  • $cookie: a reference to the $_COOKIE super global array.
  • ICanBoogie\HTTP\Request::$path_params: initialized to an empty array.
  • ICanBoogie\HTTP\Request::$query_params: a reference to the $_GET super global array.
  • ICanBoogie\HTTP\Request::$request_params: a reference to the $_POST super global array.
  • ICanBoogie\HTTP\Request::$files: a reference to the $_FILES super global array.

A request can also be created from an array of properties, in which case most of them are mapped to the $env constructor param. For instance, is_xhr set the HTTP_X_REQUESTED_WITH enviroment property to 'XMLHttpRequest'. In fact, only the following parameters are preserved:

  • path_params
  • query_params
  • request_params
  • files: The files associated with the request.
  • headers: The header fields of the request. If specified, the headers available in the

environement are ignored.

Parameters

$properties
array
$properties
$construct_args
array
$construct_args
$class_name
string
$class_name

Returns

ICanBoogie\HTTP\Request

Throws

InvalidArgumentException
in attempt to use a property that is not mapped to an environment property.

Overrides

ICanBoogie\Object::from
public static array
# get_properties_mappers( )

Returns properties to env mappers.

Returns properties to env mappers.

Returns

array
protected
# __construct( array $env = [] )

Initialize the properties ICanBoogie\HTTP\Request::$env, ICanBoogie\HTTP\Request::$headers and ICanBoogie\HTTP\Request::$context.

Initialize the properties ICanBoogie\HTTP\Request::$env, ICanBoogie\HTTP\Request::$headers and ICanBoogie\HTTP\Request::$context.

If the ICanBoogie\HTTP\Request::$params property is null it is set with an usinon of ICanBoogie\HTTP\Request::$path_params, ICanBoogie\HTTP\Request::$request_params and ICanBoogie\HTTP\Request::$query_params.

Parameters

$env
array
$env Environment of the request, usually the $_SERVER super global.
public ICanBoogie\HTTP\Response
# __invoke( string|null $method = null, array|null $params = null )

Dispatch the request.

Dispatch the request.

The ICanBoogie\HTTP\Request::$previous property is used for request chaining. The ICanBoogie\HTTP\Request::$current_request class property is set to the current request.

Parameters

$method
string|null
$method The request method. Use this parameter to override the request method.
$params
array|null
$params The request parameters. Use this parameter to override the request parameters. The ICanBoogie\HTTP\Request::$path_params, ICanBoogie\HTTP\Request::$query_params and ICanBoogie\HTTP\Request::$request_params are set to empty arrays. The provided parameters are set to the ICanBoogie\HTTP\Request::$params property. Note: If an exception is thrown during dispatch ICanBoogie\HTTP\Request::$current_request is not updated!

Returns

ICanBoogie\HTTP\Response
The response to the request.
public mixed
# __call( string $method, array $arguments )

Overrides the method to provide a virtual method for each request method.

Overrides the method to provide a virtual method for each request method.

Example:

<?php

Request::from('/api/core/aloha')->get();

Parameters

$method
string
$method
$arguments
array
$arguments

Returns

mixed

Overrides

ICanBoogie\Object::__call
public
# offsetExists( mixed $param )

Checks if the specified param exists in the request.

Checks if the specified param exists in the request.

Implementation of

ArrayAccess::offsetExists()
public
# offsetGet( mixed $param )

Get the specified param from the request.

Get the specified param from the request.

Implementation of

ArrayAccess::offsetGet()
public
# offsetSet( mixed $param, mixed $value )

Set the specified param to the specified value.

Set the specified param to the specified value.

Implementation of

ArrayAccess::offsetSet()
public
# offsetUnset( mixed $param )

Remove the specified param from the request.

Remove the specified param from the request.

Implementation of

ArrayAccess::offsetUnset()
public ArrayIterator
# getIterator( )

Returns an array iterator for the params.

Returns an array iterator for the params.

Returns

ArrayIterator

Implementation of

IteratorAggregate::getIterator()
protected ICanBoogie\HTTP\Request
# get_previous( )

Returns the previous request.

Returns the previous request.

Returns

ICanBoogie\HTTP\Request
protected ICanBoogie\HTTP\Request\Context
# get_context( )

Returns the request's context.

Returns the request's context.

Returns

ICanBoogie\HTTP\Request\Context
protected ICanBoogie\HTTP\CacheControlHeader
# get_cache_control( )

Returns the Cache-Control header.

Returns the Cache-Control header.

Returns

ICanBoogie\HTTP\CacheControlHeader
protected string
# get_script_name( )

Returns the script name.

Returns the script name.

The setter is volatile, the value is returned from the ENV key SCRIPT_NAME.

Returns

string
protected string
# get_method( )

Returns the request method.

Returns the request method.

This is the getter for the method magic property.

The method is retrieved from ICanBoogie\HTTP\Request::$env, if the key REQUEST_METHOD is not defined, the method defaults to ICanBoogie\HTTP\Request::METHOD_GET.

Returns

string

Throws

ICanBoogie\HTTP\MethodNotSupported
when the request method is not supported.
protected
# get_query_string( )

Returns the query string of the request.

Returns the query string of the request.

The value is obtained from the QUERY_STRING key of the ICanBoogie\HTTP\Request::$env array.

protected integer|null
# get_content_length( )

Returns the content lenght of the request.

Returns the content lenght of the request.

The value is obtained from the CONTENT_LENGTH key of the ICanBoogie\HTTP\Request::$env array.

Returns

integer|null
protected string|null
# get_referer( )

Returns the referer of the request.

Returns the referer of the request.

The value is obtained from the HTTP_REFERER key of the ICanBoogie\HTTP\Request::$env array.

Returns

string|null
protected string|null
# get_user_agent( )

Returns the user agent of the request.

Returns the user agent of the request.

The value is obtained from the HTTP_USER_AGENT key of the ICanBoogie\HTTP\Request::$env array.

Returns

string|null
protected boolean
# get_is_delete( )

Checks if the request method is DELETE.

Checks if the request method is DELETE.

Returns

boolean
protected boolean
# get_is_get( )

Checks if the request method is GET.

Checks if the request method is GET.

Returns

boolean
protected boolean
# get_is_head( )

Checks if the request method is HEAD.

Checks if the request method is HEAD.

Returns

boolean
protected boolean
# get_is_options( )

Checks if the request method is OPTIONS.

Checks if the request method is OPTIONS.

Returns

boolean
protected boolean
# get_is_patch( )

Checks if the request method is PATCH.

Checks if the request method is PATCH.

Returns

boolean
protected boolean
# get_is_post( )

Checks if the request method is POST.

Checks if the request method is POST.

Returns

boolean
protected boolean
# get_is_put( )

Checks if the request method is PUT.

Checks if the request method is PUT.

Returns

boolean
protected boolean
# get_is_trace( )

Checks if the request method is TRACE.

Checks if the request method is TRACE.

Returns

boolean
protected boolean
# get_is_xhr( )

Checks if the request is a XMLHTTPRequest.

Checks if the request is a XMLHTTPRequest.

Returns

boolean
protected boolean
# get_is_local( )

Checks if the request is local.

Checks if the request is local.

Returns

boolean
protected string
# get_ip( )

Returns the remote IP of the request.

Returns the remote IP of the request.

If defined, the HTTP_X_FORWARDED_FOR header is used to retrieve the original IP.

If the REMOTE_ADDR header is empty the request is considered local thus ::1 is returned.

Returns

string

See

http://en.wikipedia.org/wiki/X-Forwarded-For
protected
# get_authorization( )
protected string
# get_uri( )

Returns the REQUEST_URI environment key.

Returns the REQUEST_URI environment key.

If the REQUEST_URI key is not defined by the environment, the value is fetched from the $_SERVER array. If the key is not defined in the $_SERVER array null is returned.

Returns

string
protected integer
# get_port( )

Returns the port of the request.

Returns the port of the request.

Returns

integer
protected string
# get_path( )

Returns the path of the request, that is the REQUEST_URI without the query string.

Returns the path of the request, that is the REQUEST_URI without the query string.

Returns

string
protected string
# get_normalized_path( )

Returns the $path property normalized using the ICanBoogie\normalize_url_path() function.

Returns the $path property normalized using the ICanBoogie\normalize_url_path() function.

Returns

string
protected mixed
# get_extension( )

Returns the extension of the path info.

Returns the extension of the path info.

Returns

mixed
protected
# lazy_set_params( mixed $params )
protected array
# lazy_get_params( )

Returns the union of the ICanBoogie\HTTP\Request::$path_params, ICanBoogie\HTTP\Request::$request_params and ICanBoogie\HTTP\Request::$query_params properties.

Returns the union of the ICanBoogie\HTTP\Request::$path_params, ICanBoogie\HTTP\Request::$request_params and ICanBoogie\HTTP\Request::$query_params properties.

This method is the getter of the ICanBoogie\HTTP\Request::$params magic property.

Returns

array

Methods inherited from ICanBoogie\Object

resolve_facade_properties(), resolve_private_properties(), to_array(), to_json()

Methods inherited from ICanBoogie\ToArrayRecursive

to_array_recursive()

Methods used from ICanBoogie\ToArrayRecursiveTrait

to_array_recursive()

Methods used from ICanBoogie\PrototypeTrait

__get(), __set(), __sleep(), __wakeup(), get_prototype(), has_method(), has_property(), last_chance_get(), last_chance_set()

Magic methods summary

public ICanBoogie\HTTP\Response
# connect( )

Returns

ICanBoogie\HTTP\Response
public ICanBoogie\HTTP\Response
# delete( )

Returns

ICanBoogie\HTTP\Response
public ICanBoogie\HTTP\Response
# get( )

Returns

ICanBoogie\HTTP\Response
public ICanBoogie\HTTP\Response
# head( )

Returns

ICanBoogie\HTTP\Response
public ICanBoogie\HTTP\Response
# options( )

Returns

ICanBoogie\HTTP\Response
public ICanBoogie\HTTP\Response
# post( )

Returns

ICanBoogie\HTTP\Response
public ICanBoogie\HTTP\Response
# put( )

Returns

ICanBoogie\HTTP\Response
public ICanBoogie\HTTP\Response
# patch( )

Returns

ICanBoogie\HTTP\Response
public ICanBoogie\HTTP\Response
# trace( )

Returns

ICanBoogie\HTTP\Response

Constants summary

string METHOD_ANY 'ANY'
#
string METHOD_CONNECT 'CONNECT'
#
string METHOD_DELETE 'DELETE'
#
string METHOD_GET 'GET'
#
string METHOD_HEAD 'HEAD'
#
string METHOD_OPTIONS 'OPTIONS'
#
string METHOD_POST 'POST'
#
string METHOD_PUT 'PUT'
#
string METHOD_PATCH 'PATCH'
#
string METHOD_TRACE 'TRACE'
#

Properties summary

public static array $methods
#
protected static ICanBoogie\HTTP\Request $current_request
#

Current request.

Current request.

public array $path_params
#

Parameters extracted from the request path.

Parameters extracted from the request path.

public array $query_params
#

Parameters defined by the query string.

Parameters defined by the query string.

public array $request_params
#

Parameters defined by the request body.

Parameters defined by the request body.

public array $params
#

Union of ICanBoogie\HTTP\Request::$path_params, ICanBoogie\HTTP\Request::$request_params and ICanBoogie\HTTP\Request::$query_params.

Union of ICanBoogie\HTTP\Request::$path_params, ICanBoogie\HTTP\Request::$request_params and ICanBoogie\HTTP\Request::$query_params.

protected ICanBoogie\HTTP\Request\Context $context
#

General purpose container.

General purpose container.

public ICanBoogie\HTTP\Headers $headers
#

The headers of the request.

The headers of the request.

protected array $env
#

Request environment.

Request environment.

protected ICanBoogie\HTTP\FileList $files
#

Files associated with the request.

Files associated with the request.

protected ICanBoogie\HTTP\Request $previous
#

Previous request.

Previous request.

Magic properties

public read-only ICanBoogie\HTTP\Request\Context $context
#

the request's context.

the request's context.

public read-only ICanBoogie\HTTP\Request $previous
#

Previous request.

Previous request.

public read-only ICanBoogie\HTTP\FileList $files
#

The files associated with the request.

The files associated with the request.

public read-only boolean $authorization
#

Authorization of the request.

Authorization of the request.

public read-only integer $content_length
#

Length of the request content.

Length of the request content.

public read-only integer $cache_control
#

A ICanBoogie\HTTP\CacheControlHeader object.

A ICanBoogie\HTTP\CacheControlHeader object.

public read-only string $ip
#

Remote IP of the request.

Remote IP of the request.

public read-only boolean $is_delete
#

Is this a DELETE request?

Is this a DELETE request?

public read-only boolean $is_get
#

Is this a GET request?

Is this a GET request?

public read-only boolean $is_head
#

Is this a HEAD request?

Is this a HEAD request?

public read-only boolean $is_options
#

Is this a OPTIONS request?

Is this a OPTIONS request?

public read-only boolean $is_patch
#

Is this a PATCH request?

Is this a PATCH request?

public read-only boolean $is_post
#

Is this a POST request?

Is this a POST request?

public read-only boolean $is_put
#

Is this a PUT request?

Is this a PUT request?

public read-only boolean $is_trace
#

Is this a TRACE request?

Is this a TRACE request?

public read-only boolean $is_local
#

Is this a local request?

Is this a local request?

public read-only boolean $is_xhr
#

Is this an Ajax request?

Is this an Ajax request?

public read-only string $method
#

Method of the request.

Method of the request.

public read-only string $normalized_path
#

Path of the request normalized using the ICanBoogie\normalize_url_path() function.

Path of the request normalized using the ICanBoogie\normalize_url_path() function.

public read-only string $path
#

Path info of the request.

Path info of the request.

public read-only integer $port
#

Port of the request.

Port of the request.

public read-only string $query_string
#

Query string of the request.

Query string of the request.

public read-only string $script_name
#

Name of the entered script.

Name of the entered script.

public read-only string $referer
#

Referer of the request.

Referer of the request.

public read-only string $user_agent
#

User agent of the request.

User agent of the request.

public read-only string $uri
#

URI of the request. The QUERY_STRING value of the environment is overwritten when the instance is created with the $uri property.

URI of the request. The QUERY_STRING value of the environment is overwritten when the instance is created with the $uri property.

Magic properties inherited from ICanBoogie\Object

$prototype

Autodoc API documentation generated by ApiGen 2.8.0