class Url implements JsonSerializable

Mutable representation of a URL.

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

Traits

Strict class for better experience.

Properties

static array $defaultPorts
string $scheme
string $user
string $password
string $host
int $port
string $path
string $query
string $fragment

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, $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()

No description

string
getBaseUrl()

No description

string
getRelativeUrl()

No description

bool
isEqual(string|Url $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.

Details

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

Parameters

string|Url|UrlImmutable $url

Exceptions

InvalidArgumentException if URL is malformed

at line 113
Url setScheme(string $scheme)

Parameters

string $scheme

Return Value

Url

at line 120
string getScheme()

Return Value

string

at line 129
Url setUser(string $user)

Parameters

string $user

Return Value

Url

at line 136
string getUser()

Return Value

string

at line 145
Url setPassword(string $password)

Parameters

string $password

Return Value

Url

at line 152
string getPassword()

Return Value

string

at line 161
Url setHost(string $host)

Parameters

string $host

Return Value

Url

at line 169
string getHost()

Return Value

string

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

Returns the part of domain.

Parameters

int $level

Return Value

string

at line 189
Url setPort(int $port)

Parameters

int $port

Return Value

Url

at line 196
int|null getPort()

Return Value

int|null

at line 205
Url setPath(string $path)

Parameters

string $path

Return Value

Url

at line 215
string getPath()

Return Value

string

at line 225
Url setQuery($query)

Parameters

$query

Return Value

Url

at line 236
Url appendQuery($query)

Parameters

$query

Return Value

Url

at line 245
string getQuery()

Return Value

string

at line 251
array getQueryParameters()

Return Value

array

at line 260
mixed getQueryParameter(string $name)

Parameters

string $name

Return Value

mixed

at line 273
Url setQueryParameter(string $name, $value)

Parameters

string $name
$value

Return Value

Url

at line 283
Url setFragment(string $fragment)

Parameters

string $fragment

Return Value

Url

at line 290
string getFragment()

Return Value

string

at line 296
string getAbsoluteUrl()

Return Value

string

at line 307
string getAuthority()

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

Return Value

string

at line 324
string getHostUrl()

Returns the scheme and authority part of URI.

Return Value

string

at line 331
string getBasePath()

Return Value

string

at line 338
string getBaseUrl()

Return Value

string

at line 344
string getRelativeUrl()

Return Value

string

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

URL comparison.

Parameters

string|Url $url

Return Value

bool

at line 376
Url canonicalize()

Transforms URL to canonical form.

Return Value

Url

at line 388
string __toString()

Return Value

string

at line 394
string jsonSerialize()

Return Value

string

at line 401
final array export()

Return Value

array

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

Parses query string.

Parameters

string $s

Return Value

array