Zend_Controller_Request_Http

HTTP request object for use with Zend_Controller family.

uses
package Zend_Controller
subpackage Request
inherited_from \Zend_Controller_Request_Abstract

 Methods

Constructor

__construct(string|\Zend_Uri $uri = null) : void

If a $uri is passed, the object will attempt to populate itself using that information.

Parameters

$uri

string\Zend_Uri

Exceptions

\Zend_Controller_Request_Exception when invalid URI passed

Access values contained in the superglobals as public members Order of precedence: 1. GET, 2. POST, 3. COOKIE, 4. SERVER, 5. ENV

__get(string $key) : mixed
see

Parameters

$key

string

Returns

mixed

Check to see if a property is set

__isset(string $key) : boolean

Parameters

$key

string

Returns

boolean

Set values

__set(string $key, mixed $value) : void

In order to follow __get(), which operates on a number of superglobals, setting values through overloading is not allowed and will raise an exception. Use setParam() instead.

Parameters

$key

string

$value

mixed

Exceptions

\Zend_Controller_Request_Exception

Unset all user parameters

clearParams() : \Zend_Controller_Request_Abstract
Inherited

Returns

\Zend_Controller_Request_Abstract

Alias to __get

get(string $key) : mixed

Parameters

$key

string

Returns

mixed

Retrieve the action key

getActionKey() : string
Inherited

Returns

string

Retrieve the action name

getActionName() : string
Inherited

Returns

string

Retrieve an alias

getAlias(string $name) : string | null

Retrieve the actual key represented by the alias $name.

Parameters

$name

string

Returns

stringnullReturns null when no alias exists

Retrieve the list of all aliases

getAliases() : array

Returns

array

Everything in REQUEST_URI before PATH_INFO not including the filename <img src="<?=$basePath?>/images/zend.png"/>

getBasePath() : string

Returns

string

Everything in REQUEST_URI before PATH_INFO <form action="<?=$baseUrl?>/news/submit" method="POST"/>

getBaseUrl($raw = false) : string

Parameters

$raw

Returns

string

Get the client's IP addres

getClientIp(boolean $checkProxy = true) : string

Parameters

$checkProxy

boolean

Returns

string

Retrieve the controller key

getControllerKey() : string
Inherited

Returns

string

Retrieve the controller name

getControllerName() : string
Inherited

Returns

string

Retrieve a member of the $_COOKIE superglobal

getCookie(string $key = null, mixed $default = null) : mixed

If no $key is passed, returns the entire $_COOKIE array.

todo How to retrieve from nested arrays

Parameters

$key

string

$default

mixed

Default value to use if key not found

Returns

mixedReturns null if key does not exist

Retrieve a member of the $_ENV superglobal

getEnv(string $key = null, mixed $default = null) : mixed

If no $key is passed, returns the entire $_ENV array.

Parameters

$key

string

$default

mixed

Default value to use if key not found

Returns

mixedReturns null if key does not exist

Return the value of the given HTTP header. Pass the header name as the plain, HTTP-specified header name. Ex.: Ask for 'Accept' to get the Accept header, 'Accept-Encoding' to get the Accept-Encoding header.

getHeader(string $header) : string | false

Parameters

$header

string

HTTP header name

Exceptions

\Zend_Controller_Request_Exception

Returns

stringfalseHTTP header value, or false if not found

Get the HTTP host.

getHttpHost() : string

"Host" ":" host [ ":" port ] ; Section 3.2.2 Note the HTTP Host header is not the same as the URI host. It includes the port while the URI host doesn't.

Returns

string

Return the method by which the request was made

getMethod() : string

Returns

string

Retrieve the module key

getModuleKey() : string
Inherited

Returns

string

Retrieve the module name

getModuleName() : string
Inherited

Returns

string

Retrieve a parameter

getParam(mixed $key, mixed $default = null) : mixed

Retrieves a parameter from the instance. Priority is in the order of userland parameters (see \setParam()), $_GET, $_POST. If a parameter matching the $key is not found, null is returned.

If the $key is an alias, the actual key aliased will be used.

inherited_from \Zend_Controller_Request_Abstract::getParam()

Parameters

$key

mixed

$default

mixed

Default value to use if key not found

Returns

mixed

Get an action parameter

getParam(string $key, mixed $default = null) : mixed
Inherited

Parameters

$key

string

$default

mixed

Default value to use if key not found

Returns

mixed

Get list of allowed parameter sources

getParamSources() : array

Returns

array

Retrieve an array of parameters

getParams() : array

Retrieves a merged array of parameters, with precedence of userland params (see \setParam()), $_GET, $_POST (i.e., values in the userland params will take precedence over all others).

inherited_from \Zend_Controller_Request_Abstract::getParams()

Returns

array

Get all action parameters

getParams() : array
Inherited

Returns

array

Returns everything between the BaseUrl and QueryString.

getPathInfo() : string

This value is calculated instead of reading PATH_INFO directly from $_SERVER due to cross-platform differences.

Returns

string

Retrieve a member of the $_POST superglobal

getPost(string $key = null, mixed $default = null) : mixed

If no $key is passed, returns the entire $_POST array.

todo How to retrieve from nested arrays

Parameters

$key

string

$default

mixed

Default value to use if key not found

Returns

mixedReturns null if key does not exist

Retrieve a member of the $_GET superglobal

getQuery(string $key = null, mixed $default = null) : mixed

If no $key is passed, returns the entire $_GET array.

todo How to retrieve from nested arrays

Parameters

$key

string

$default

mixed

Default value to use if key not found

Returns

mixedReturns null if key does not exist

Return the raw body of the request, if present

getRawBody() : string | false

Returns

stringfalseRaw body, or false if not present

Returns the REQUEST_URI taking into account platform differences between Apache and IIS

getRequestUri() : string

Returns

string

Get the request URI scheme

getScheme() : string

Returns

string

Retrieve a member of the $_SERVER superglobal

getServer(string $key = null, mixed $default = null) : mixed

If no $key is passed, returns the entire $_SERVER array.

Parameters

$key

string

$default

mixed

Default value to use if key not found

Returns

mixedReturns null if key does not exist

Retrieve a single user param (i.e, a param specific to the object and not the environment)

getUserParam(string $key, string $default = null) : mixed
Inherited

Parameters

$key

string

$default

string

Default value to use if key not found

Returns

mixed

Retrieve only user params (i.e, any param specific to the object and not the environment)

getUserParams() : array
Inherited

Returns

array

Alias to __isset()

has(string $key) : boolean

Parameters

$key

string

Returns

boolean

Was the request made by DELETE?

isDelete() : boolean

Returns

boolean

Determine if the request has been dispatched

isDispatched() : boolean
Inherited

Returns

boolean

Is this a Flash request?

isFlashRequest() : boolean

Returns

boolean

Was the request made by GET?

isGet() : boolean

Returns

boolean

Was the request made by HEAD?

isHead() : boolean

Returns

boolean

Was the request made by OPTIONS?

isOptions() : boolean

Returns

boolean

Was the request made by PATCH?

isPatch() : boolean

Returns

boolean

Was the request made by POST?

isPost() : boolean

Returns

boolean

Was the request made by PUT?

isPut() : boolean

Returns

boolean

Is https secure request

isSecure() : boolean

Returns

boolean

Is the request a Javascript XMLHttpRequest?

isXmlHttpRequest() : boolean

Should work with Prototype/Script.aculo.us, possibly others.

Returns

boolean

Alias to __set()

set(string $key, mixed $value) : void

Parameters

$key

string

$value

mixed

Set the action key

setActionKey(string $key) : \Zend_Controller_Request_Abstract
Inherited

Parameters

$key

string

Returns

\Zend_Controller_Request_Abstract

Set the action name

setActionName(string $value) : \Zend_Controller_Request_Abstract
Inherited

Parameters

$value

string

Returns

\Zend_Controller_Request_Abstract

Set a key alias

setAlias(string $name, string $target) : \Zend_Controller_Request_Http

Set an alias used for key lookups. $name specifies the alias, $target specifies the actual key to use.

Parameters

$name

string

$target

string

Returns

\Zend_Controller_Request_Http

Set the base path for the URL

setBasePath(string|null $basePath = null) : \Zend_Controller_Request_Http

Parameters

$basePath

stringnull

Returns

\Zend_Controller_Request_Http

Set the base URL of the request; i.e., the segment leading to the script name

setBaseUrl(mixed $baseUrl = null) : \Zend_Controller_Request_Http

E.g.:

  • /admin
  • /myapp
  • /subdir/index.php

Do not use the full URI when providing the base. The following are examples of what not to use:

If no $baseUrl is provided, attempts to determine the base URL from the environment, using SCRIPT_FILENAME, SCRIPT_NAME, PHP_SELF, and ORIG_SCRIPT_NAME in its determination.

Parameters

$baseUrl

mixed

Returns

\Zend_Controller_Request_Http

Set the controller key

setControllerKey(string $key) : \Zend_Controller_Request_Abstract
Inherited

Parameters

$key

string

Returns

\Zend_Controller_Request_Abstract

Set the controller name to use

setControllerName(string $value) : \Zend_Controller_Request_Abstract
Inherited

Parameters

$value

string

Returns

\Zend_Controller_Request_Abstract

Set flag indicating whether or not request has been dispatched

setDispatched(boolean $flag = true) : \Zend_Controller_Request_Abstract
Inherited

Parameters

$flag

boolean

Returns

\Zend_Controller_Request_Abstract

Set the module key

setModuleKey(string $key) : \Zend_Controller_Request_Abstract
Inherited

Parameters

$key

string

Returns

\Zend_Controller_Request_Abstract

Set the module name to use

setModuleName(string $value) : \Zend_Controller_Request_Abstract
Inherited

Parameters

$value

string

Returns

\Zend_Controller_Request_Abstract

Set a userland parameter

setParam(mixed $key, mixed $value) : \Zend_Controller_Request_Http

Uses $key to set a userland parameter. If $key is an alias, the actual key will be retrieved and used to set the parameter.

inherited_from \Zend_Controller_Request_Abstract::setParam()

Parameters

$key

mixed

$value

mixed

Returns

\Zend_Controller_Request_Http

Set an action parameter

setParam(string $key, mixed $value) : \Zend_Controller_Request_Abstract
Inherited

A $value of null will unset the $key if it exists

Parameters

$key

string

$value

mixed

Returns

\Zend_Controller_Request_Abstract

Set allowed parameter sources

setParamSources(array $paramSources = array()) : \Zend_Controller_Request_Http

Can be empty array, or contain one or more of '_GET' or '_POST'.

Parameters

$paramSources

Returns

\Zend_Controller_Request_Http

Set parameters

setParams(array $params) : \Zend_Controller_Request_Http

Set one or more parameters. Parameters are set as userland parameters, using the keys specified in the array.

inherited_from \Zend_Controller_Request_Abstract::setParams()

Parameters

$params

array

Returns

\Zend_Controller_Request_Http

Set action parameters en masse; does not overwrite

setParams(array $array) : \Zend_Controller_Request_Abstract
Inherited

Null values will unset the associated key.

Parameters

$array

array

Returns

\Zend_Controller_Request_Abstract

Set the PATH_INFO string

setPathInfo(string|null $pathInfo = null) : \Zend_Controller_Request_Http

Parameters

$pathInfo

stringnull

Returns

\Zend_Controller_Request_Http

Set POST values

setPost(string|array $spec, null|mixed $value = null) : \Zend_Controller_Request_Http

Parameters

$spec

stringarray

$value

nullmixed

Returns

\Zend_Controller_Request_Http

Set GET values

setQuery(string|array $spec, null|mixed $value = null) : \Zend_Controller_Request_Http

Parameters

$spec

stringarray

$value

nullmixed

Returns

\Zend_Controller_Request_Http

Set the REQUEST_URI on which the instance operates

setRequestUri(string $requestUri = null) : \Zend_Controller_Request_Http

If no request URI is passed, uses the value in $_SERVER['REQUEST_URI'], $_SERVER['HTTP_X_REWRITE_URL'], or $_SERVER['ORIG_PATH_INFO'] + $_SERVER['QUERY_STRING'].

Parameters

$requestUri

string

Returns

\Zend_Controller_Request_Http

 Properties

 

Action

$_action : string

Default

 

Action key for retrieving action from params

$_actionKey : string

Default

'action'
 

Alias keys for request parameters

$_aliases : array

Default

array()
 

Base path of request

$_basePath : string

Default

null
 

Base URL of request

$_baseUrl : string

Default

null
 

Controller

$_controller : string

Default

 

Controller key for retrieving controller from params

$_controllerKey : string

Default

'controller'
 

Has the action been dispatched?

$_dispatched : boolean

Default

false
 

Module

$_module : string

Default

 

Module key for retrieving module from params

$_moduleKey : string

Default

'module'
 

Allowed parameter sources

$_paramSources : array

Default

array('_GET', '_POST')
 

Instance parameters

$_params : array

Default

array()
inherited_from \Zend_Controller_Request_Abstract::_params
 

Request parameters

$_params : array

Default

array()
 

PATH_INFO

$_pathInfo : string

Default

''
 

Raw request body

$_rawBody : string | false

Default

 

REQUEST_URI

$_requestUri : \string;

Default

 Constants

 

Scheme for http

SCHEME_HTTP = 'http' 
 

Scheme for https

SCHEME_HTTPS = 'https'