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 $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(UrlImmutable|null $url = null)

No description

Url
setScheme(string $scheme)

No description

string
getScheme()

No description

Url
setUser(string $user) deprecated

No description

string
getUser() deprecated

No description

Url
setPassword(string $password) deprecated

No description

string
getPassword() deprecated

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

int|null
getDefaultPort()

No description

Url
setPath(string $path)

No description

string
getPath()

No description

Url
setQuery(string|array $query)

No description

Url
appendQuery(string|array $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(UrlImmutable $url)

URL comparison.

Url
canonicalize()

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.

static bool
isAbsolute(string $url)

Determines if URL is absolute, ie if it starts with a scheme followed by colon.

static string
removeDotSegments(string $path)

Normalizes a path by handling and removing relative path references like '.', '..' and directory traversal.

Details

at line 69
__construct(UrlImmutable|null $url = null)

No description

Parameters

UrlImmutable|null $url

Exceptions

InvalidArgumentException

at line 92
Url setScheme(string $scheme)

No description

Parameters

string $scheme

Return Value

Url

at line 99
string getScheme()

No description

Return Value

string

at line 106
Url setUser(string $user) deprecated

deprecated

No description

Parameters

string $user

Return Value

Url

at line 114
string getUser() deprecated

deprecated

No description

Return Value

string

at line 121
Url setPassword(string $password) deprecated

deprecated

No description

Parameters

string $password

Return Value

Url

at line 129
string getPassword() deprecated

deprecated

No description

Return Value

string

at line 135
Url setHost(string $host)

No description

Parameters

string $host

Return Value

Url

at line 143
string getHost()

No description

Return Value

string

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

Returns the part of domain.

Parameters

int $level

Return Value

string

at line 164
Url setPort(int $port)

No description

Parameters

int $port

Return Value

Url

at line 171
int|null getPort()

No description

Return Value

int|null

at line 177
int|null getDefaultPort()

No description

Return Value

int|null

at line 183
Url setPath(string $path)

No description

Parameters

string $path

Return Value

Url

at line 194
string getPath()

No description

Return Value

string

at line 200
Url setQuery(string|array $query)

No description

Parameters

string|array $query

Return Value

Url

at line 207
Url appendQuery(string|array $query)

No description

Parameters

string|array $query

Return Value

Url

at line 216
string getQuery()

No description

Return Value

string

at line 222
array getQueryParameters()

No description

Return Value

array

at line 228
mixed getQueryParameter(string $name)

No description

Parameters

string $name

Return Value

mixed

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

No description

Parameters

string $name
mixed $value

Return Value

Url

at line 241
Url setFragment(string $fragment)

No description

Parameters

string $fragment

Return Value

Url

at line 248
string getFragment()

No description

Return Value

string

at line 254
string getAbsoluteUrl()

No description

Return Value

string

at line 265
string getAuthority()

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

Return Value

string

at line 282
string getHostUrl()

Returns the scheme and authority part of URI.

Return Value

string

at line 290
string getBasePath() deprecated

deprecated use UrlScript::getBasePath() instead

No description

Return Value

string

at line 298
string getBaseUrl() deprecated

deprecated use UrlScript::getBaseUrl() instead

No description

Return Value

string

at line 305
string getRelativeUrl() deprecated

deprecated use UrlScript::getRelativeUrl() instead

No description

Return Value

string

at line 314
bool isEqual(UrlImmutable $url)

URL comparison.

Parameters

UrlImmutable $url

Return Value

bool

at line 338
Url canonicalize()

Transforms URL to canonical form.

Return Value

Url

at line 351
string __toString()

No description

Return Value

string

at line 357
string jsonSerialize()

No description

Return Value

string

at line 364
final array export()

internal  
 

No description

Return Value

array

at line 390
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 410
static array parseQuery(string $s)

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

Parameters

string $s

Return Value

array

at line 423
static bool isAbsolute(string $url)

Determines if URL is absolute, ie if it starts with a scheme followed by colon.

Parameters

string $url

Return Value

bool

at line 432
static string removeDotSegments(string $path)

Normalizes a path by handling and removing relative path references like '.', '..' and directory traversal.

Parameters

string $path

Return Value

string

Traits

SmartObject