Helper for returning the current server URL (optionally with request URI)

 Methods

View helper entry point: Returns the current host's URL like http://site.com

__invoke(string | bool $requestUri) : string

Parameters

$requestUri

stringbool

[optional] if true, the request URI found in $_SERVER will be appended as a path. If a string is given, it will be appended as a path. Default is to not append any path.

Returns

stringserver url

Returns host

getHost() : string

Returns

stringhost

Retrieve the server port

getPort() : int | null

Returns

intnull

Returns scheme (typically http or https)

getScheme() : string

Returns

stringscheme (typically http or https)

Get the view object

getView() : null | \Zend\View\Renderer\RendererInterface
Inherited

inherited_from \Zend\View\Helper\AbstractHelper::getView()

Returns

Sets host

setHost(string $host) : \Zend\View\Helper\ServerUrl

Parameters

$host

string

new host

Returns

\Zend\View\Helper\ServerUrlfluent interface, returns self

Set server port

setPort(int $port) : \Zend\View\Helper\ServerUrl

Parameters

$port

int

Returns

Sets scheme (typically http or https)

setScheme(string $scheme) : \Zend\View\Helper\ServerUrl

Parameters

$scheme

string

new scheme (typically http or https)

Returns

\Zend\View\Helper\ServerUrlfluent interface, returns self

Set flag indicating whether or not to query proxy servers

setUseProxy(bool $useProxy) : \Zend\View\Helper\ServerUrl

Parameters

$useProxy

bool

Returns

Set the View object

setView(\Zend\View\Renderer\RendererInterface $view) : \Zend\View\Helper\AbstractHelper
Inherited

inherited_from \Zend\View\Helper\AbstractHelper::setView()

Parameters

Returns

Detect the host based on headers

detectHost() : void

Detect the port

detectPort() : null

Returns

null

Detect the scheme

detectScheme() : null

Returns

null

Detect if a proxy is in use, and, if so, set the host based on it

setHostFromProxy() : bool

Returns

bool

Set port based on detected proxy headers

setPortFromProxy() : bool

Returns

bool

Set the current scheme based on detected proxy headers

setSchemeFromProxy() : bool

Returns

bool

 Properties

 

Host (including port)

$host : string

 

Port

$port : int

 

Scheme

$scheme : string

 

Whether or not to query proxy servers for address

$useProxy : bool

 

View object

$view : \Zend\View\Renderer\RendererInterface
Inherited

inherited_from \Zend\View\Helper\AbstractHelper::$$view