class Url implements JsonSerializable

Mutable representation of a URL.

scheme  user  password  host  port      path        query    fragment
  |      |      |        |      |        |            |         |
/--\   /--\ /------\ /-------\ /--\/------------\ /--------\ /------\
http://john:x0y17575@nette.org:8042/en/manual.php?name=param#fragment  <-- absoluteUrl
\______\__________________________/
    |               |
 hostUrl        authority

Properties

static array $defaultPorts
string $scheme
string $user
string $password
string $host
int $port
string $path
string $query
string $fragment
string read-only $absoluteUrl
string read-only $authority
string read-only $hostUrl
string read-only $basePath
string read-only $baseUrl
string read-only $relativeUrl
array read-only $queryParameters

Methods

__construct(string|Url|UrlImmutable $url = null)

No description

Url
setScheme(string $scheme)

No description

string
getScheme()

No description

Url
setUser(string $user)

No description

string
getUser()

No description

Url
setPassword(string $password)

No description

string
getPassword()

No description

Url
setHost(string $host)

No description

string
getHost()

No description

string
getDomain(int $level = 2)

Returns the part of domain.

Url
setPort(int $port)

No description

int|null
getPort()

No description

Url
setPath(string $path)

No description

string
getPath()

No description

Url
setQuery($query)

No description

Url
appendQuery($query)

No description

string
getQuery()

No description

array
getQueryParameters()

No description

mixed
getQueryParameter(string $name)

No description

Url
setQueryParameter(string $name, mixed $value)

No description

Url
setFragment(string $fragment)

No description

string
getFragment()

No description

string
getAbsoluteUrl()

No description

string
getAuthority()

Returns the [user[:pass]@]host[:port] part of URI.

string
getHostUrl()

Returns the scheme and authority part of URI.

string
getBasePath() deprecated

No description

string
getBaseUrl() deprecated

No description

string
getRelativeUrl() deprecated

No description

bool
isEqual(string|Url $url)

URL comparison.

Url
canonicalize() deprecated

Transforms URL to canonical form.

string
__toString()

No description

string
jsonSerialize()

No description

array
export()

No description

static string
unescape(string $s, string $reserved = '%;/?:@&=+$,')

Similar to rawurldecode, but preserves reserved chars encoded.

static array
parseQuery(string $s)

Parses query string. Is affected by directive arg_separator.input.

Details

at line 84
__construct(string|Url|UrlImmutable $url = null)

No description

Parameters

string|Url|UrlImmutable $url

Exceptions

InvalidArgumentException

at line 111
Url setScheme(string $scheme)

No description

Parameters

string $scheme

Return Value

Url

at line 118
string getScheme()

No description

Return Value

string

at line 125
Url setUser(string $user)

No description

Parameters

string $user

Return Value

Url

at line 132
string getUser()

No description

Return Value

string

at line 139
Url setPassword(string $password)

No description

Parameters

string $password

Return Value

Url

at line 146
string getPassword()

No description

Return Value

string

at line 153
Url setHost(string $host)

No description

Parameters

string $host

Return Value

Url

at line 161
string getHost()

No description

Return Value

string

at line 170
string getDomain(int $level = 2)

Returns the part of domain.

Parameters

int $level

Return Value

string

at line 183
Url setPort(int $port)

No description

Parameters

int $port

Return Value

Url

at line 190
int|null getPort()

No description

Return Value

int|null

at line 197
Url setPath(string $path)

No description

Parameters

string $path

Return Value

Url

at line 208
string getPath()

No description

Return Value

string

at line 218
Url setQuery($query)

No description

Parameters

$query

Return Value

Url

at line 229
Url appendQuery($query)

No description

Parameters

$query

Return Value

Url

at line 238
string getQuery()

No description

Return Value

string

at line 244
array getQueryParameters()

No description

Return Value

array

at line 251
mixed getQueryParameter(string $name)

No description

Parameters

string $name

Return Value

mixed

at line 265
Url setQueryParameter(string $name, mixed $value)

No description

Parameters

string $name
mixed $value

null unsets the parameter

Return Value

Url

at line 273
Url setFragment(string $fragment)

No description

Parameters

string $fragment

Return Value

Url

at line 280
string getFragment()

No description

Return Value

string

at line 286
string getAbsoluteUrl()

No description

Return Value

string

at line 297
string getAuthority()

Returns the [user[:pass]@]host[:port] part of URI.

Return Value

string

at line 314
string getHostUrl()

Returns the scheme and authority part of URI.

Return Value

string

at line 322
string getBasePath() deprecated

deprecated use UrlScript::getBasePath() instead

No description

Return Value

string

at line 330
string getBaseUrl() deprecated

deprecated use UrlScript::getBaseUrl() instead

No description

Return Value

string

at line 337
string getRelativeUrl() deprecated

deprecated use UrlScript::getRelativeUrl() instead

No description

Return Value

string

at line 347
bool isEqual(string|Url $url)

URL comparison.

Parameters

string|Url $url

Return Value

bool

at line 373
Url canonicalize() deprecated

deprecated

Transforms URL to canonical form.

Return Value

Url

at line 386
string __toString()

No description

Return Value

string

at line 392
string jsonSerialize()

No description

Return Value

string

at line 399
final array export()

internal  
 

No description

Return Value

array

at line 425
static string unescape(string $s, string $reserved = '%;/?:@&=+$,')

Similar to rawurldecode, but preserves reserved chars encoded.

Parameters

string $s
string $reserved

Return Value

string

at line 445
static array parseQuery(string $s)

Parses query string. Is affected by directive arg_separator.input.

Parameters

string $s

Return Value

array

Traits

SmartObject