Url
in package
Parses and generates URLs based on URL parts. In favor of performance, URL parts are not validated.
Table of Contents
Properties
- $fragment : mixed
- $host : mixed
- $password : mixed
- $path : mixed
- $port : mixed
- $query : QueryString
- $scheme : mixed
- $username : mixed
Methods
- __clone() : mixed
- Clone the URL
- __construct() : mixed
- Create a new URL from URL parts
- __toString() : string
- Returns the URL as a URL string
- addPath() : Url
- Add a relative path to the currently set path.
- buildUrl() : string
- Build a URL from parse_url parts. The generated URL will be a relative URL if a scheme or host are not provided.
- combine() : Url
- Combine the URL with another URL. Follows the rules specific in RFC 3986 section 5.4.
- factory() : Url
- Factory method to create a new URL from a URL string
- getFragment() : null|string
- Get the fragment part of the URL
- getHost() : string
- Get the host part of the URL
- getParts() : array<string|int, mixed>
- Get the parts of the URL as an array
- getPassword() : null|string
- Get the password part of the URL
- getPath() : string
- Get the path part of the URL
- getPathSegments() : array<string|int, mixed>
- Get the path segments of the URL as an array
- getPort() : int|null
- Get the port part of the URl. Will return the default port for a given scheme if no port has been set.
- getQuery() : QueryString
- Get the query part of the URL as a QueryString object
- getScheme() : string
- Get the scheme part of the URL
- getUsername() : null|string
- Get the username part of the URl
- isAbsolute() : bool
- Check if this is an absolute URL
- normalizePath() : Url
- Normalize the URL so that double slashes and relative paths are removed
- setFragment() : Url
- Set the fragment part of the URL
- setHost() : Url
- Set the host of the request.
- setPassword() : Url
- Set the password part of the URL
- setPath() : Url
- Set the path part of the URL
- setPort() : Url
- Set the port part of the URL
- setQuery() : Url
- Set the query part of the URL
- setScheme() : Url
- Set the scheme part of the URL (http, https, ftp, etc)
- setUsername() : Url
- Set the username part of the URL
- addQuery() : mixed
Properties
$fragment
protected
mixed
$fragment
$host
protected
mixed
$host
$password
protected
mixed
$password
$path
protected
mixed
$path
= ''
$port
protected
mixed
$port
$query
protected
QueryString
$query
Query part of the URL
$scheme
protected
mixed
$scheme
$username
protected
mixed
$username
Methods
__clone()
Clone the URL
public
__clone() : mixed
__construct()
Create a new URL from URL parts
public
__construct(string $scheme, string $host[, string $username = null ][, string $password = null ][, int $port = null ][, string $path = null ][, QueryString|array<string|int, mixed>|string $query = null ][, string $fragment = null ]) : mixed
Parameters
- $scheme : string
-
Scheme of the URL
- $host : string
-
Host of the URL
- $username : string = null
-
Username of the URL
- $password : string = null
-
Password of the URL
- $port : int = null
-
Port of the URL
- $path : string = null
-
Path of the URL
- $query : QueryString|array<string|int, mixed>|string = null
-
Query string of the URL
- $fragment : string = null
-
Fragment of the URL
__toString()
Returns the URL as a URL string
public
__toString() : string
Return values
stringaddPath()
Add a relative path to the currently set path.
public
addPath(string $relativePath) : Url
Parameters
- $relativePath : string
-
Relative path to add
Return values
UrlbuildUrl()
Build a URL from parse_url parts. The generated URL will be a relative URL if a scheme or host are not provided.
public
static buildUrl(array<string|int, mixed> $parts) : string
Parameters
- $parts : array<string|int, mixed>
-
Array of parse_url parts
Return values
stringcombine()
Combine the URL with another URL. Follows the rules specific in RFC 3986 section 5.4.
public
combine(string $url[, bool $strictRfc3986 = false ]) : Url
Parameters
- $url : string
-
Relative URL to combine with
- $strictRfc3986 : bool = false
-
Set to true to use strict RFC 3986 compliance when merging paths. When first released, Guzzle used an incorrect algorithm for combining relative URL paths. In order to not break users, we introduced this flag to allow the merging of URLs based on strict RFC 3986 section 5.4.1. This means that "http://a.com/foo/baz" merged with "bar" would become "http://a.com/foo/bar". When this value is set to false, it would become "http://a.com/foo/baz/bar".
Tags
Return values
Urlfactory()
Factory method to create a new URL from a URL string
public
static factory(string $url) : Url
Parameters
- $url : string
-
Full URL used to create a Url object
Tags
Return values
UrlgetFragment()
Get the fragment part of the URL
public
getFragment() : null|string
Return values
null|stringgetHost()
Get the host part of the URL
public
getHost() : string
Return values
stringgetParts()
Get the parts of the URL as an array
public
getParts() : array<string|int, mixed>
Return values
array<string|int, mixed>getPassword()
Get the password part of the URL
public
getPassword() : null|string
Return values
null|stringgetPath()
Get the path part of the URL
public
getPath() : string
Return values
stringgetPathSegments()
Get the path segments of the URL as an array
public
getPathSegments() : array<string|int, mixed>
Return values
array<string|int, mixed>getPort()
Get the port part of the URl. Will return the default port for a given scheme if no port has been set.
public
getPort() : int|null
Return values
int|nullgetQuery()
Get the query part of the URL as a QueryString object
public
getQuery() : QueryString
Return values
QueryStringgetScheme()
Get the scheme part of the URL
public
getScheme() : string
Return values
stringgetUsername()
Get the username part of the URl
public
getUsername() : null|string
Return values
null|stringisAbsolute()
Check if this is an absolute URL
public
isAbsolute() : bool
Return values
boolnormalizePath()
Normalize the URL so that double slashes and relative paths are removed
public
normalizePath() : Url
Return values
UrlsetFragment()
Set the fragment part of the URL
public
setFragment(string $fragment) : Url
Parameters
- $fragment : string
-
Fragment to set
Return values
UrlsetHost()
Set the host of the request.
public
setHost(string $host) : Url
Parameters
- $host : string
-
Host to set (e.g. www.yahoo.com, yahoo.com)
Return values
UrlsetPassword()
Set the password part of the URL
public
setPassword(string $password) : Url
Parameters
- $password : string
-
Password to set
Return values
UrlsetPath()
Set the path part of the URL
public
setPath(array<string|int, mixed>|string $path) : Url
Parameters
- $path : array<string|int, mixed>|string
-
Path string or array of path segments
Return values
UrlsetPort()
Set the port part of the URL
public
setPort(int $port) : Url
Parameters
- $port : int
-
Port to set
Return values
UrlsetQuery()
Set the query part of the URL
public
setQuery(QueryString|string|array<string|int, mixed> $query) : Url
Parameters
- $query : QueryString|string|array<string|int, mixed>
-
Query to set
Return values
UrlsetScheme()
Set the scheme part of the URL (http, https, ftp, etc)
public
setScheme(string $scheme) : Url
Parameters
- $scheme : string
-
Scheme to set
Return values
UrlsetUsername()
Set the username part of the URL
public
setUsername(string $username) : Url
Parameters
- $username : string
-
Username to set
Return values
UrladdQuery()
private
addQuery(QueryString $new, mixed $strictRfc386) : mixed
Parameters
- $new : QueryString
- $strictRfc386 : mixed