Overview
  • Namespace
  • Class
  • Tree

Namespaces

  • Modulework
    • Modules
      • Http
        • Exceptions
        • Utilities
  • PHP

Classes

  • Cookie
  • JsonResponse
  • RedirectResponse
  • Request
  • Response

Class Request

Request This class represents the current HTTP request. It exposes 6 public vars (objects) for getting information For some there are methods for convience.

Namespace: Modulework\Modules\Http
Located at Modulework/Modules/Http/Request.php

Methods summary

public static Modulework\Modules\Http\Request
# makeFromGlobals( )

Create the Request object from PHP _ENV (or superglobals)

Create the Request object from PHP _ENV (or superglobals)

Returns

Modulework\Modules\Http\Request
The new Request object
public
# __construct( array $query = array(), array $request = array(), array $cookies = array(), array $files = array(), array $server = array() )

Constructor

Constructor

Parameters

$query
array
$query GET
$request
array
$request POST
$cookies
array
$cookies COOKIE
$files
array
$files FILES
$server
array
$server SERVER
public string
# __toString( )

Displays the Request in the following format: PROTOCOLL VERB >> BASEURI

Displays the Request in the following format: PROTOCOLL VERB >> BASEURI

Returns

string
[description]
public
# init( array $query = array(), array $request = array(), array $cookies = array(), array $files = array(), array $server = array() )

Initialize all parameters

Initialize all parameters

Parameters

$query
array
$query GET
$request
array
$request POST
$cookies
array
$cookies COOKIE
$files
array
$files FILES
$server
array
$server SERVER
public
# applyChanges( )

Write changes to the Request to the globals

Write changes to the Request to the globals

public static Modulework\Modules\Http\Request
# mock( string $uri, string $method = 'GET', array $request = array(), array $cookies = array(), array $files = array(), array $server = array() )

Mock an request by providing a URI only, to feed more info is still possible

Mock an request by providing a URI only, to feed more info is still possible

Parameters

$uri
string
$uri The URI
$method
string
$method The HTTP request method
$request
array
$request The _POST values
$cookies
array
$cookies The _COOKIES
$files
array
$files The _FILES
$server
array
$server The _SERVER values

Returns

Modulework\Modules\Http\Request
A new instance based on the info provided
public static string
# normalizeQuery( string $query )

Normalize a query string

Normalize a query string

Parameters

$query
string
$query Query String

Returns

string
The normalized version of $query
public string
# getMethod( )

Returns the request method

Returns the request method

Returns

string
The request method
public
# setMethod( string $method )

Mock the request method

Mock the request method

Parameters

$method
string
$method The request method
public string
# getScheme( )

Returns either http or https calls isSecure()

Returns either http or https calls isSecure()

Returns

string
The scheme (http | https)
public string
# getHttpHost( )

Returns the HTTP Host (with port if not default)

Returns the HTTP Host (with port if not default)

For example: localhost or localhost:4000

Returns

string
The host
public string
# getHost( )

Returns the host of the server

Returns the host of the server

Returns

string
The host of this server
public
# setHost( string $host )

Set the host in the header

Set the host in the header

Parameters

$host
string
$host The new host
public string
# getPort( )

Port for the Request

Port for the Request

Returns

string
the port
public array
# getAcceptedEncodings( )

Retrieve the accepted encoding types from the HTTP headers

Retrieve the accepted encoding types from the HTTP headers

Returns

array
The accepted encodings
public string
# getBaseUri( )

Get the BaseUri Calls once: generateBaseUri()

Get the BaseUri Calls once: generateBaseUri()

Returns

string
The base uri for the request
public string
# getBaseUrl( )

The base URL

The base URL

Returns

string
The base URL
public string
# getPath( )

Returns the path. Examples (this class was initalized at /dev on localhost):

Returns the path. Examples (this class was initalized at /dev on localhost):

  • http://localhost/dev -> ''
  • http://localhost/dev/more -> '/more'
  • http://localhost/dev/more?foo -> '/more'

Returns

string
The path
public string
# getBasePath( )

Returns the base path from the root, for example if this class was constructed in the subfolder 'foo' this method would return 'foo' for this uri: http://localhost/foo/index.php

Returns the base path from the root, for example if this class was constructed in the subfolder 'foo' this method would return 'foo' for this uri: http://localhost/foo/index.php

Returns

string
The raw path
public string
# root( )

Returns the root URL

Returns the root URL

Returns

string
The root URL
public string
# url( )

Returns the URL (without query string)

Returns the URL (without query string)

Returns

string
The URL
public array
# segments( )

Returns all URI segments (or empty array if path = '/')

Returns all URI segments (or empty array if path = '/')

Returns

array
The URI segments
public mixed
# segment( integer $index, mixed $default = null )

Get a URI segment 1 based index

Get a URI segment 1 based index

Parameters

$index
integer
$index The index
$default
mixed
$default If the segement does not exists this will get returned

Returns

mixed
The URI segment | $default
public boolean
# isMethod( string $method )

Check if the request method equals the given

Check if the request method equals the given

Parameters

$method
string
$method The method to test

Returns

boolean
TRUE if match
public boolean
# isAjax( )

Wrapper for isXmlHttpRequest

Wrapper for isXmlHttpRequest

Returns

boolean
TRUE if it is a XMLHttpRequest
public boolean
# isXmlHttpRequest( )

Is the request of type XMLHttpRequest

Is the request of type XMLHttpRequest

Returns

boolean
TRUE if it is a XMLHttpRequest
public boolean
# isSecure( )

Check for HTTPS connection

Check for HTTPS connection

Returns

boolean
TRUE if it is a HTTPS connection
public string
# getClientIp( )

Returns the client' s IP address

Returns the client' s IP address

Returns

string
The IP
public string
# getScript( )

Returns the current script name

Returns the current script name

Returns

string
The script name
protected string
# generateBaseUri( )

Generate the BaseUri

Generate the BaseUri

Returns

string
The base uri
protected string
# generateBaseUrl( )

Generate the BaseUrl

Generate the BaseUrl

Returns

string
The base url
protected
# generateBasePath( )
protected
# generatePath( )
protected static string|false
# getPrefixUrlEncoded( string $str, string $pre )

Returns the string prefix if it' s the string' s prefix (URL Encoded) false otherwise

Returns the string prefix if it' s the string' s prefix (URL Encoded) false otherwise

Parameters

$str
string
$str The urlencoded string
$pre
string
$pre The NOT encoeded prefix

Returns

string|false
The prefix as it is encoded in $str or false

Magic methods summary

Properties summary

public Modulework\Modules\Http\ArrayCase $query
#

The ArrayCase for the QueryString (_GET)

The ArrayCase for the QueryString (_GET)

public Modulework\Modules\Http\ArrayCase $request
#

The ArrayCase for the POST request (_POST)

The ArrayCase for the POST request (_POST)

public Modulework\Modules\Http\ServerCase $server
#

The ArrayCase for the server varibales (_SERVER)

The ArrayCase for the server varibales (_SERVER)

public Modulework\Modules\Http\FileCase $files
#

The ArrayCase for the files attached to the request (_FILES)

The ArrayCase for the files attached to the request (_FILES)

public Modulework\Modules\Http\ArrayCase $cookies
#

The ArrayCase for the cookies (_COOKIE)

The ArrayCase for the cookies (_COOKIE)

public Modulework\Modules\Http\HeaderCase $headers
#

The ArrayCase for the HTTP headers

The ArrayCase for the HTTP headers

protected string $uri
#

The URI of this request

The URI of this request

protected string $path
#

The path information of this request

The path information of this request

protected string $baseUrl
#

The base URL of this request

The base URL of this request

protected string $basePath
#

The base path of this request

The base path of this request

protected string $method
#

The HTTP verb (GET/POST/PUT/DELETE)

The HTTP verb (GET/POST/PUT/DELETE)

API documentation generated by ApiGen 2.8.0