Overview

Namespaces

  • None
  • Wei
    • Validator

Classes

  • Apc
  • App
  • ArrayCache
  • Asset
  • Base
  • BaseCache
  • BaseController
  • Bicache
  • Cache
  • Config
  • Cookie
  • Couchbase
  • Counter
  • Db
  • DbCache
  • E
  • Env
  • Error
  • FileCache
  • Gravatar
  • Http
  • Lock
  • Logger
  • Memcache
  • Memcached
  • MongoCache
  • Password
  • PhpError
  • PhpFileCache
  • Pinyin
  • Record
  • Redis
  • Request
  • Response
  • Router
  • SafeUrl
  • Session
  • Soap
  • T
  • Ua
  • Upload
  • Url
  • Uuid
  • Validate
  • View
  • WeChatApp
  • Wei
  • Overview
  • Namespace
  • Class

Class Request

A service that handles the HTTP request data

The methods are derived from code of the Zend Framework (2.1-dev 2013-04-01) * getBaseUrl * getRequestUri * detectBaseUrl * detectRequestUri

Wei\Base
Extended by Wei\Request implements ArrayAccess, Countable, IteratorAggregate
Namespace: Wei
Copyright: Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
License: New BSD License
Author: Twin Huang twinhuang@qq.com
Link: https://github.com/zendframework/zf2/blob/master/library/Zend/Http/PhpEnvironment/Request.php
Link: for the canonical source repository
Located at Request.php
Methods summary
public
# __construct( array $options = array() )

Constructor

Constructor

Parameters

$options

Throws

InvalidArgumentException
When option "wei" is not an instance of "Wei\Wei"

Overrides

Wei\Base::__construct()
public string|null
# __invoke( string $name, mixed $default = '' )

Returns a stringify or user defined($default) parameter value

Returns a stringify or user defined($default) parameter value

Parameters

$name
The parameter name
$default
The default parameter value if the parameter does not exist

Returns

string|null
The parameter value
public string|null
# get( string $name, mixed $default = null )

Returns a stringify or user defined($default) parameter value

Returns a stringify or user defined($default) parameter value

Parameters

$name
The parameter name
$default
The default parameter value if the parameter does not exist

Returns

string|null
The parameter value
public integer
# getInt( string $name, integer|null $min = null, integer|null $max = null )

Returns a integer value in the specified range

Returns a integer value in the specified range

Parameters

$name
The parameter name
$min
The min value for the parameter
$max
The max value for the parameter

Returns

integer
The parameter value
public mixed
# getInArray( string $name, array $array )

Returns a parameter value in the specified array, if not in, returns the first element instead

Returns a parameter value in the specified array, if not in, returns the first element instead

Parameters

$name
The parameter name
$array
The array to be search

Returns

mixed
The parameter value
public
# set( string|array $name, mixed $value = null )

Set parameter value

Set parameter value

Parameters

$name
The parameter name or A key-value array
$value
The parameter value

Returns


$this
public
# remove( string $name )

Remove parameter by specified name

Remove parameter by specified name

Parameters

$name
The parameter name

Returns


$this
public
# clear( )

Clear all parameter data

Clear all parameter data

Returns


$this
public boolean
# offsetExists( string $offset )

Check if the offset exists

Check if the offset exists

Parameters

$offset

Returns

boolean

Implementation of

ArrayAccess::offsetExists()
public mixed &
# offsetGet( string $offset )

Get the offset value

Get the offset value

Parameters

$offset

Returns

mixed

Implementation of

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

Set the offset value

Set the offset value

Parameters

$offset
$value

Returns

mixed

Implementation of

ArrayAccess::offsetSet()
public
# offsetUnset( string $offset )

Unset the offset

Unset the offset

Parameters

$offset

Implementation of

ArrayAccess::offsetUnset()
public
# fromArray( array $array = array() )

Merge data from array

Merge data from array

Parameters

$array

Returns


$this
public array
# toArray( )

Return the source array of the object

Return the source array of the object

Returns

array
public integer
# count( )

Return the length of data

Return the length of data

Returns

integer
the length of data

Implementation of

Countable::count()
public string
# getScheme( )

Returns the request scheme

Returns the request scheme

Returns

string
public string
# getHost( )

Returns the request host

Returns the request host

Returns

string
public Wei\Request
# setRequestUri( string $requestUri )

Set the request URI.

Set the request URI.

Parameters

$requestUri

Returns

Wei\Request
public string
# getRequestUri( )

Get the request URI.

Get the request URI.

Returns

string
public Wei\Request
# setBaseUrl( string $baseUrl )

Set the base URL.

Set the base URL.

Parameters

$baseUrl

Returns

Wei\Request
public string
# getBaseUrl( )

Get the base URL.

Get the base URL.

Returns

string
public
# setPathInfo( string $pathInfo )

Set the path info

Set the path info

Parameters

$pathInfo

Returns


$this
public string
# getPathInfo( )

Return request path info

Return request path info

Returns

string
public string
# getUrl( )

Returns the full URL, which contains scheme://domain[:port]/[baseUrl][PathInfo][?queryString]

Returns the full URL, which contains scheme://domain[:port]/[baseUrl][PathInfo][?queryString]

The full URL do not contain the fragment, for it never sent to the server

Returns

string
public string
# getSchemeAndHost( )

Returns scheme and host which contains scheme://domain[:port]

Returns scheme and host which contains scheme://domain[:port]

Returns

string
public string
# getUrlFor( string $path )

Generates absolute URL for specified path

Generates absolute URL for specified path

Parameters

$path

Returns

string
public string
# getIp( string $default = '0.0.0.0' )

Returns the client IP address

Returns the client IP address

If the IP could not receive from the server parameter, or the IP address is not valid, return the $default value instead

Parameters

$default
The default ip address

Returns

string

Link

http://en.wikipedia.org/wiki/X-Forwarded-For
public string
# getMethod( )

Returns the HTTP request method

Returns the HTTP request method

Returns

string
public
# setMethod( string $method )

Set the HTTP request method

Set the HTTP request method

Parameters

$method
The value of method

Returns


$this
public boolean
# isMethod( string $method )

Check if the current request method is the specified string

Check if the current request method is the specified string

Parameters

$method
The method name to be compared

Returns

boolean
public boolean
# isGet( )

Check if the current request method is GET

Check if the current request method is GET

Returns

boolean
public boolean
# isPost( )

Check if the current request method is POST

Check if the current request method is POST

Returns

boolean
public boolean
# isAjax( )

Check if the current request is an ajax(XMLHttpRequest) request

Check if the current request is an ajax(XMLHttpRequest) request

Returns

boolean
public array &
# getParameterReference( string $type )

Returns the HTTP parameters reference

Returns the HTTP parameters reference

Parameters

$type
The parameter type, could be get, post, cookie, or server

Returns

array
The parameters array

Throws

InvalidArgumentException
When parameter type is unknown
public string
# getContent( )

Returns the request message body

Returns the request message body

Returns

string
public
# setContent( string $content )

Set the request message body

Set the request message body

Parameters

$content

Returns


$this
public string
# __toString( )

Returns the request message string

Returns the request message string

Returns

string
public mixed
# getServer( string $name, mixed $default = null )

Return the server and execution environment parameter value ($_SERVER)

Return the server and execution environment parameter value ($_SERVER)

Parameters

$name
The name of parameter
$default
The default parameter value if the parameter does not exist

Returns

mixed
public
# setServer( string $name, string $value )

Set the server and execution environment parameter value ($_SERVER)

Set the server and execution environment parameter value ($_SERVER)

Parameters

$name
$value

Returns


$this
public mixed
# getQuery( string $name, mixed $default = null )

Return the URL query parameter value ($_GET)

Return the URL query parameter value ($_GET)

Parameters

$name
The name of parameter
$default
The default parameter value if the parameter does not exist

Returns

mixed
public
# setQuery( string $name, string $value )

Set the URL query parameter value ($_GET)

Set the URL query parameter value ($_GET)

Parameters

$name
$value

Returns


$this
public array &
# getQueries( )

Return the URL query parameter values ($_GET)

Return the URL query parameter values ($_GET)

Returns

array
public mixed
# getPost( string $name, mixed $default = null )

Return the HTTP request parameters value ($_POST)

Return the HTTP request parameters value ($_POST)

Parameters

$name
The name of parameter
$default
The default parameter value if the parameter does not exist

Returns

mixed
public
# setPost( string $name, string $value )

Set the HTTP request parameters value ($_POST)

Set the HTTP request parameters value ($_POST)

Parameters

$name
$value

Returns


$this
public array
# getHeaders( )

Returns the HTTP request headers

Returns the HTTP request headers

Returns

array
public boolean
# isPage( string $page )

Check if the request page is specified page

Check if the request page is specified page

Parameters

$page

Returns

boolean
protected string
# detectRequestUri( )

Detect the base URI for the request

Detect the base URI for the request

Looks at a variety of criteria in order to attempt to autodetect a base URI, including rewrite URIs, proxy URIs, etc.

Returns

string
protected string
# detectBaseUrl( )

Auto-detect the base path from the request environment

Auto-detect the base path from the request environment

Uses a variety of criteria in order to detect the base URL of the request (i.e., anything additional to the document root).

The base URL includes the schema, host, and port, in addition to the path.

Returns

string
protected string
# detectPathInfo( )

Detect the path info for the request

Detect the path info for the request

Returns

string
public ArrayIterator
# getIterator( )

Retrieve an array iterator

Retrieve an array iterator

Returns

ArrayIterator

Implementation of

IteratorAggregate::getIterator()
public boolean
# accept( string $mine )

Check if the accept header is starts with the specified MIME type

Check if the accept header is starts with the specified MIME type

Parameters

$mine

Returns

boolean
public boolean
# acceptJson( )

Check if the request is accept a JSON response

Check if the request is accept a JSON response

Returns

boolean
Methods inherited from Wei\Base
__call(), __get(), getOption(), setOption()
Properties summary
protected array $data

The request parameters, equals to $_REQUEST when $fromGlobal is true

The request parameters, equals to $_REQUEST when $fromGlobal is true

# array()
protected array $gets

The URL query parameters, equal to $_GET when $fromGlobal is true

The URL query parameters, equal to $_GET when $fromGlobal is true

# array()
protected array $posts

The HTTP request parameters, equal to $_POST when $fromGlobal is true

The HTTP request parameters, equal to $_POST when $fromGlobal is true

# array()
protected array $cookies

The cookie parameters, equal to $_COOKIE when $fromGlobal is true

The cookie parameters, equal to $_COOKIE when $fromGlobal is true

# array()
protected array $servers

The server parameters, equal to $_SERVER when $fromGlobal is true

The server parameters, equal to $_SERVER when $fromGlobal is true

# array()
protected array $files

The upload file parameters, equal to $_FILES when $fromGlobal is true

The upload file parameters, equal to $_FILES when $fromGlobal is true

# array()
protected string $content

The request message body

The request message body

#
protected boolean $fromGlobal

Whether create request parameter from PHP global variable

Whether create request parameter from PHP global variable

# true
protected boolean $overwriteMethod

Whether overwrite the request method when "_method" request parameter is present

Whether overwrite the request method when "_method" request parameter is present

# true
protected boolean $overwriteAjax

Whether add "X-Requested-With: XMLHttpRequest" header when "_ajax" request parameter is present

Whether add "X-Requested-With: XMLHttpRequest" header when "_ajax" request parameter is present

# true
protected boolean $overwriteFormat

Whether allow detect accept MIME type by "_format" request parameter

Whether allow detect accept MIME type by "_format" request parameter

# true
protected string $baseUrl
#
protected string $pathInfo
#
protected string $requestUri
#
protected string $method

The HTTP request method

The HTTP request method

#
Properties inherited from Wei\Base
$providers, $wei
Wei Framework API documentation generated by ApiGen