Constants

URL_CLEAN

URL_CLEAN

URL_APPEND

URL_APPEND

Properties

$config

$config : array<mixed,>

Type

array<mixed,> — store the configuration in this array.

$urlType

$urlType : 

Type

$siteUrl

$siteUrl : 

Type

— Siteurl to prepend to all absolute urls created.

$baseUrl

$baseUrl : 

Type

$scriptName

$scriptName : 

Type

$staticSiteUrl

$staticSiteUrl : 

Type

— Siteurl to prepend to all absolute urls for assets.

$staticBaseUrl

$staticBaseUrl : 

Type

Methods

configure()

configure(array|string  $what) : self

Read configuration from file or array, if a file, first check in ANAX_APP_PATH/config and then in ANAX_INSTALL_PATH/config.

Parameters

array|string $what

is an array with key/value config options or a file to be included which returns such an array.

Throws

\Anax\Configure\Exception

when argument if not a file nor an array.

Returns

self —

for chaining.

getConfig()

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

Helper function for reading values from the configuration and appy default values where configuration item is missing.

Parameters

string $key

matching a key in the config array.

string $default

value returned when config item is not found.

Returns

mixed —

or null if key does not exists.

setDefaultsFromConfiguration()

setDefaultsFromConfiguration() : \Anax\Url\this.

Set default values from configuration.

Returns

\Anax\Url\this.

create()

create(string  $uri = null, string  $baseuri = null) : string

Create an url and prepending the baseUrl.

Parameters

string $uri

part of uri to use when creating an url. "" or null means baseurl to current frontcontroller.

string $baseuri

optional base to prepend uri.

Returns

string —

as resulting url.

createRelative()

createRelative(string  $uri = null) : string

Create an url and prepend the baseUrl to the directory of the frontcontroller.

Parameters

string $uri

part of uri to use when creating an url. "" or null means baseurl to directory of the current frontcontroller.

Returns

string —

as resulting url.

asset()

asset(string  $uri = null) : string

Create an url for a static asset.

Parameters

string $uri

part of uri to use when creating an url.

Returns

string —

as resulting url.

setSiteUrl()

setSiteUrl(string  $url) : self

Set the siteUrl to prepend all absolute urls created.

Parameters

string $url

part of url to use when creating an url.

Returns

self

setBaseUrl()

setBaseUrl(string  $url) : self

Set the baseUrl to prepend all relative urls created.

Parameters

string $url

part of url to use when creating an url.

Returns

self

setStaticSiteUrl()

setStaticSiteUrl(string  $url) : self

Set the siteUrl to prepend absolute urls for assets.

Parameters

string $url

part of url to use when creating an url.

Returns

self

setStaticBaseUrl()

setStaticBaseUrl(string  $url) : self

Set the baseUrl to prepend relative urls for assets.

Parameters

string $url

part of url to use when creating an url.

Returns

self

setScriptName()

setScriptName(string  $name) : self

Set the scriptname to use when creating URL_APPEND urls.

Parameters

string $name

as the scriptname, for example index.php.

Returns

self

setUrlType()

setUrlType(string  $type) : self

Set the type of urls to be generated, URL_CLEAN, URL_APPEND.

Parameters

string $type

what type of urls to create.

Throws

\Anax\Url\Anax\Url\Exception

Returns

self

slugify()

slugify(string  $str) : \Anax\Url\str

Create a slug of a string, to be used as url.

Parameters

string $str

the string to format as slug.

Returns

\Anax\Url\str —

the formatted slug.