Overview

Namespaces

  • MvcCore
    • Ext
      • Auth
        • Virtual
      • Debug
        • Tracy
      • Form
        • Core
        • Validators
      • Request
      • Router
        • Lang
      • View
        • Helpers
  • None

Classes

  • Config
  • Controller
  • Debug
  • Model
  • Request
  • Response
  • Route
  • Router
  • Session
  • Tool
  • View
  • Overview
  • Namespace
  • Class
  • Tree

Class Request

Core request: - linear request url parsing from $_SERVER into local properties describing url sections - params reading from $_GET/$_POST or direct input (in JSON or in query string) - params cleaning by developer rules

Direct known subclasses

MvcCore\Ext\Request\ApacheDpi, MvcCore\Ext\Request\Cli
Namespace: MvcCore
Located at mvccore/src/MvcCore/Request.php
Methods summary
public static MvcCore\Request
# GetInstance( array & $server, array & $get, array & $post )

Get everytime new instance of http request, global variables should be changed and injected here to get different request object from currently called real request.

Get everytime new instance of http request, global variables should be changed and injected here to get different request object from currently called real request.

Parameters

$server
$get
$post

Returns

MvcCore\Request
public
# __construct( array & $server, array & $get, array & $post )

Get everytime new instance of http request, global variables should be changed and injected here to get different request object from currently called real request.

Get everytime new instance of http request, global variables should be changed and injected here to get different request object from currently called real request.

Parameters

$server
$get
$post
public mixed|MvcCore\Request
# __call( string $rawName, array $arguments = array() )

Sets any custom property ('PropertyName') by $request->SetPropertyName('value'), which is not necessary to define previously or gets previously defined property ('PropertyName') by $request->GetPropertyName(); Throws exception if no property defined by get call or if virtual call begins with anything different from 'set' or 'get'. This method returns custom value for get and $request instance for set.

Sets any custom property ('PropertyName') by $request->SetPropertyName('value'), which is not necessary to define previously or gets previously defined property ('PropertyName') by $request->GetPropertyName(); Throws exception if no property defined by get call or if virtual call begins with anything different from 'set' or 'get'. This method returns custom value for get and $request instance for set.

Parameters

$rawName
$arguments

Returns

mixed|MvcCore\Request

Throws

Exception
public mixed
# __get( string $name )

Universal getter, if property not defined, NULL is returned.

Universal getter, if property not defined, NULL is returned.

Parameters

$name

Returns

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

Universal setter, if property not defined, it's automaticly declarated.

Universal setter, if property not defined, it's automaticly declarated.

Parameters

$name
$value
public MvcCore\Request
# SetParam( string $name = "", string $value = "" )

Set directly raw param value without any change

Set directly raw param value without any change

Parameters

$name
$value

Returns

MvcCore\Request
public string
# GetParam( string $name = "", string $pregReplaceAllowedChars = "a-zA-Z0-9_/\-\.\@" )

Get param value, filtered for characters defined as second argument to use them in preg_replace().

Get param value, filtered for characters defined as second argument to use them in preg_replace().

Parameters

$name
$pregReplaceAllowedChars

Returns

string
public boolean
# IsAppRequest( )

Return boolean flag if request target is anything different than 'Controller:Asset'

Return boolean flag if request target is anything different than 'Controller:Asset'

Returns

boolean
protected
# initScriptName( )

Initialize index.php script name.

Initialize index.php script name.

protected
# initAppRoot( )

Initialize application root directory.

Initialize application root directory.

protected
# initMethod( )

Initialize http method.

Initialize http method.

protected
# initBasePath( )

Complete base application path like: /localhost/my/development/direcotry/www

Complete base application path like: /localhost/my/development/direcotry/www

protected
# initProtocol( )

Initialize http protocol.

Initialize http protocol.

protected
# initParsedUrlSegments( )

Initialize url segments parsed by parse_url() php method.

Initialize url segments parsed by parse_url() php method.

protected
# initHttpParams( )

Initialize params from global $_GET and (global $_POST or direct 'php://input').

Initialize params from global $_GET and (global $_POST or direct 'php://input').

protected
# initPath( )

Initialize request path.

Initialize request path.

protected
# initReferer( )

Initialize referer safely if any.

Initialize referer safely if any.

protected
# initUrlCompositions( )

Initialize url compositions.

Initialize url compositions.

Constants summary
string PROTOCOL_HTTP
# 'http:'
string PROTOCOL_HTTPS
# 'https:'
string METHOD_GET
# 'GET'
string METHOD_POST
# 'POST'
Properties summary
public string $Lang

Language international code, lowercase, not used by default. To use this variable - install \MvcCore\Router extension \MvcCoreExt\Router\Lang Example: 'en'

Language international code, lowercase, not used by default. To use this variable - install \MvcCore\Router extension \MvcCoreExt\Router\Lang Example: 'en'

# ''
public string $Locale

Country/locale code, uppercase, not used by default. To use this variable - install \MvcCore\Router extension \MvcCoreExt\Router\Locale Example: 'US'

Country/locale code, uppercase, not used by default. To use this variable - install \MvcCore\Router extension \MvcCoreExt\Router\Locale Example: 'US'

# ''
public string $Protocol

Http protocol: 'http:' | 'https:' Example: 'http:'

Http protocol: 'http:' | 'https:' Example: 'http:'

# ''
public string $ServerName

Application server name - domain without any port. Example: 'localhost'

Application server name - domain without any port. Example: 'localhost'

# ''
public string $Host

Application host with port if there is any. Example: 'localhost:88'

Application host with port if there is any. Example: 'localhost:88'

# ''
public string $Port

Http port parsed by parse_url(). Example: '88'

Http port parsed by parse_url(). Example: '88'

# ''
public string $Path

Requested path in from application root (if mod_rewrite enabled), never with query string. Example: '/products/page/2'

Requested path in from application root (if mod_rewrite enabled), never with query string. Example: '/products/page/2'

# ''
public string $Query

Uri query string without question mark. Example: 'param-1=value-1&param-2=value-2&param-3[]=value-3-a&param-3[]=value-3-b'

Uri query string without question mark. Example: 'param-1=value-1&param-2=value-2&param-3[]=value-3-a&param-3[]=value-3-b'

# ''
public mixed $Fragment

Uri fragment parsed by parse_url() Example: '#any-sublink-path'

Uri fragment parsed by parse_url() Example: '#any-sublink-path'

# ''
public string $ScriptName

Php requested script name path from application root. Example: '/index.php'

Php requested script name path from application root. Example: '/index.php'

# ''
public string $AppRoot

Application root path in hard drive: C:/www/my/development/direcotry/www

Application root path in hard drive: C:/www/my/development/direcotry/www

# ''
public string $BasePath

Base app directory path after domain, if application is placed in domain subdirectory Example: full url: 'http://localhost:88/my/development/direcotry/www/requested/path/after/domain?with=possible&query=string' base path: '/my/development/direcotry/www'

Base app directory path after domain, if application is placed in domain subdirectory Example: full url: 'http://localhost:88/my/development/direcotry/www/requested/path/after/domain?with=possible&query=string' base path: '/my/development/direcotry/www'

# ''
public string $RequestPath

Request path after domain with possible query string Example: '/requested/path/after/app/root?with=possible&query=string'

Request path after domain with possible query string Example: '/requested/path/after/app/root?with=possible&query=string'

# ''
public string $DomainUrl

Url to requested domain and possible port. Example: 'http://domain:88'

Url to requested domain and possible port. Example: 'http://domain:88'

# ''
public string $BaseUrl

Base url to application root. Example: 'http://domain:88/my/development/direcotry/www'

Base url to application root. Example: 'http://domain:88/my/development/direcotry/www'

# ''
public string $RequestUrl

Request url including scheme, domain, port, path, without any query string Example: ''http://localhost:88/my/development/direcotry/www/requested/path/after/domain'

Request url including scheme, domain, port, path, without any query string Example: ''http://localhost:88/my/development/direcotry/www/requested/path/after/domain'

# ''
public string $FullUrl

Request url including scheme, domain, port, path and with query string Example: 'http://localhost:88/my/development/direcotry/www/requested/path/after/domain?with=possible&query=string'

Request url including scheme, domain, port, path and with query string Example: 'http://localhost:88/my/development/direcotry/www/requested/path/after/domain?with=possible&query=string'

# ''
public string $Method

Http method (uppercase) - GET, POST, PUT, HEAD... Example: 'GET'

Http method (uppercase) - GET, POST, PUT, HEAD... Example: 'GET'

# ''
public string $Referer

Referer url if any, safely readed by: filter_var($_SERVER['HTTP_REFERER'], FILTER_SANITIZE_URL); Example: 'GET'

Referer url if any, safely readed by: filter_var($_SERVER['HTTP_REFERER'], FILTER_SANITIZE_URL); Example: 'GET'

# ''
public array $Params

Request params array, with keys defined in route or by query string, always with controller and action keys completed by router. Example: array('controller' => 'default', 'action' => 'default', 'user' => "' OR 1=1;-- with raw danger value!"); To get safe param value - use: $request->GetParam('user', 'a-zA-Z0-9');

Request params array, with keys defined in route or by query string, always with controller and action keys completed by router. Example: array('controller' => 'default', 'action' => 'default', 'user' => "' OR 1=1;-- with raw danger value!"); To get safe param value - use: $request->GetParam('user', 'a-zA-Z0-9');

# array()
public string $MediaSiteKey

Media site key - 'full' | 'tablet' | 'mobile' To use this variable - install \MvcCore\Router extension \MvcCoreExt\Router\Media Example: 'full'

Media site key - 'full' | 'tablet' | 'mobile' To use this variable - install \MvcCore\Router extension \MvcCoreExt\Router\Media Example: 'full'

# ''
protected array $serverGlobals

Content of $_SERVER global variable

Content of $_SERVER global variable

# array()
protected array $getGlobals

Content of $_GET global variable

Content of $_GET global variable

# array()
protected array $postGlobals

Content of $_POST global variable

Content of $_POST global variable

# array()
protected array $indexScriptName

Requested script name

Requested script name

# ''
protected mixed $appRequest

Request flag if request targets internal package asset or not, - 0 - request is Controller:Asset call for internal package asset - 1 - request is classic application request

Request flag if request targets internal package asset or not, - 0 - request is Controller:Asset call for internal package asset - 1 - request is classic application request

# -1
MvcCore API documentation generated by ApiGen