Alpha Framework 3.0.0 API Documentation
  • Namespace
  • Class

Namespaces

  • Alpha
    • Controller
      • Front
    • Exception
    • Model
      • Type
    • Task
    • Util
      • Backup
      • Cache
      • Code
        • Highlight
        • Metric
      • Config
      • Convertor
      • Email
      • Extension
      • Feed
      • File
      • Graph
      • Helper
      • Http
        • Filter
        • Session
      • Image
      • Logging
      • Search
      • Security
      • Service
    • View
      • Renderer
        • Html
        • Json
      • Widget

Classes

  • AgentUtils
  • PHPServerUtils
  • Request
  • Response

Class Request

A class to encapsulate a HTTP request.

Namespace: Alpha\Util\Http
Copyright:

Copyright (c) 2018, John Collins (founder of Alpha Framework). All rights reserved.

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the
following conditions are met:

* Redistributions of source code must retain the above
  copyright notice, this list of conditions and the
  following disclaimer.
* Redistributions in binary form must reproduce the above
  copyright notice, this list of conditions and the
  following disclaimer in the documentation and/or other
  materials provided with the distribution.
* Neither the name of the Alpha Framework nor the names
  of its contributors may be used to endorse or promote
  products derived from this software without specific
  prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

License: The BSD License
Author: John Collins dev@alphaframework.org
Since: 2.0
Located at Util/Http/Request.php

Methods summary

public
# __construct( array $overrides = array() )

Builds up the request based on available PHP super globals, in addition to any overrides provided (useful for testing).

Builds up the request based on available PHP super globals, in addition to any overrides provided (useful for testing).

Parameters

$overrides
Hash array of PHP super globals to override

Throws

Alpha\Exception\IllegalArguementException

Since

2.0
public string
# getMethod( )

Get the HTTP method of this request.

Get the HTTP method of this request.

Returns

string

Since

2.0
public
# setMethod( string $method )

Set the HTTP method of this request.

Set the HTTP method of this request.

Parameters

$method

Throws

Alpha\Exception\IllegalArguementException

Since

2.0
public array
# getHeaders( )

Return all headers on this request.

Return all headers on this request.

Returns

array

Since

2.0
public string
# getHeader( string $key, mixed $default = null )

Get the header matching the key provided.

Get the header matching the key provided.

Parameters

$key
The key to search for
$default
If key is not found, return this instead

Returns

string

Since

2.0
public array
# getCookies( )

Return all cookies on this request.

Return all cookies on this request.

Returns

array

Since

2.0
public mixed
# getCookie( string $key, mixed $default = null )

Get the cookie matching the key provided.

Get the cookie matching the key provided.

Parameters

$key
The key to search for
$default
If key is not found, return this instead

Returns

mixed

Since

2.0
public array
# getParams( )

Return all params on this request.

Return all params on this request.

Returns

array

Since

2.0
public string
# getParam( string $key, mixed $default = null )

Get the param matching the key provided.

Get the param matching the key provided.

Parameters

$key
The key to search for
$default
If key is not found, return this instead

Returns

string

Since

2.0
public
# addParams( array $params )

Append the hash array provided to the params for this request.

Append the hash array provided to the params for this request.

Parameters

$params
hash array of values to add to the request params

Since

2.0
public
# setParams( array $params )

Set the params array.

Set the params array.

Parameters

$params
hash array of values to set as the request params

Since

2.0
public array
# getFiles( )

Return all files on this request.

Return all files on this request.

Returns

array

Since

2.0
public mixed
# getFile( string $key, mixed $default = null )

Get the file matching the key provided.

Get the file matching the key provided.

Parameters

$key
The key to search for
$default
If key is not found, return this instead

Returns

mixed

Since

2.0
public string
# getBody( )

Get the request body if one was provided.

Get the request body if one was provided.

Returns

string

Since

2.0
public string
# getAccept( )

Get the Accept header of the request.

Get the Accept header of the request.

Returns

string

Since

2.0
public string
# getContentType( )

Get the Content-Type header of the request.

Get the Content-Type header of the request.

Returns

string

Since

2.0
public string
# getContentLength( )

Get the Content-Length header of the request.

Get the Content-Length header of the request.

Returns

string

Since

2.0
public string
# getHost( )

Get the host name of the client that sent the request.

Get the host name of the client that sent the request.

Returns

string

Since

2.0
public string
# getURI( )

Get the URI that was requested.

Get the URI that was requested.

Returns

string

Since

2.0
public string
# getURL( )

Get the URL that was requested.

Get the URL that was requested.

Returns

string

Since

2.0
public string
# getIP( )

Get the IP address of the client that sent the request.

Get the IP address of the client that sent the request.

Returns

string

Since

2.0
public string
# getReferrer( )

Get the Referrer header of the request.

Get the Referrer header of the request.

Returns

string

Since

2.0
public string
# getUserAgent( )

Get the User-Agent header of the request.

Get the User-Agent header of the request.

Returns

string

Since

2.0
public string
# getQueryString( )

Get the query string provided on the request.

Get the query string provided on the request.

Returns

string

Since

2.0
public
# parseParamsFromRoute( string $route, array $defaultParams = array() )

Parses the route provided to extract matching params of the route from this request's URI.

Parses the route provided to extract matching params of the route from this request's URI.

Parameters

$route
The route with parameter names, e.g. /user/{username}
$defaultParams
Optional hash array of default request param values to use if they are missing from URI

Since

2.0
public boolean
# isSecureURI( )

Checks to see if the request contains a secure/encrypted token.

Checks to see if the request contains a secure/encrypted token.

Returns

boolean

Since

2.0
Alpha Framework 3.0.0 API Documentation API documentation generated by ApiGen