__construct()
__toString()
encodePath()
encodeQueryFragment()
encodeUserInfo()
getEscaper()
getFragment()
getHost()
getPath()
getPort()
getQuery()
getQueryAsArray()
getScheme()
getUserInfo()
isAbsolute()
isValid()
isValidRelative()
makeRelative()
merge()
normalize()
parse()
parseScheme()
removePathDotSegments()
resolve()
setEscaper()
setFragment()
setHost()
setPath()
setPort()
setQuery()
setScheme()
setUserInfo()
toString()
validateHost()
validatePath()
validatePort()
validateQueryFragment()
validateScheme()
validateUserInfo()
decodeUrlEncodedChars()
isValidDnsHostname()
isValidIpAddress()
isValidRegName()
normalizeFragment()
normalizeHost()
normalizePath()
normalizePort()
normalizeQuery()
normalizeScheme()
reset()
$defaultPorts
$escaper
$fragment
$host
$path
$port
$query
$scheme
$userInfo
$validHostTypes
$validSchemes
CHAR_GEN_DELIMS
CHAR_QUERY_DELIMS
CHAR_RESERVED
CHAR_SUB_DELIMS
CHAR_UNRESERVED
HOST_ALL
HOST_DNS
HOST_DNS_OR_IPV4
HOST_DNS_OR_IPV4_OR_IPV6
HOST_DNS_OR_IPV4_OR_IPV6_OR_REGNAME
HOST_DNS_OR_IPV6
HOST_DNS_OR_IPVANY
HOST_IPV4
HOST_IPV6
HOST_IPVANY
HOST_IPVFUTURE
HOST_REGNAME
Generic URI handler
__toString() : string
stringencodePath(string $path) : string
Will replace all characters which are not strictly allowed in the path part with percent-encoded representation
string
\Zend\Uri\Exception\InvalidArgumentException |
|---|
stringencodeQueryFragment(string $input) : string
Note that query and fragment encoding allows more unencoded characters than the usual rawurlencode() function would usually return - for example '/' and ':' are allowed as literals.
string
\Zend\Uri\Exception\InvalidArgumentException |
|---|
stringencodeUserInfo(string $userInfo) : string
getFragment() : string | null
stringnull
getHost() : string | null
stringnull
getPath() : string | null
stringnull
getPort() : int | null
intnull
getQuery() : string | null
stringnull
getQueryAsArray() : array
This is an extension to RFC-3986 but is quite useful when working with most common URI types
arraygetScheme() : string | null
stringnull
getUserInfo() : string | null
stringnull
isAbsolute() : bool
boolisValid() : bool
Note that a relative URI may still be valid
boolisValidRelative() : bool
boolmakeRelative(\Zend\Uri\Uri | string $baseUri) : \Zend\Uri\Uri
This is the opposite of resolving a relative link - i.e. creating a relative reference link from an original URI and a base URI.
If the two URIs do not intersect (e.g. the original URI is not in any way related to the base URI) the URI will not be modified.
\Zend\Uri\Uristring
merge(\Zend\Uri\Uri | string $baseUri, \Zend\Uri\Uri | string $relativeUri) : \Zend\Uri\Uri
This convenience method wraps ::resolve() to allow users to quickly create new absolute URLs without the need to instantiate and clone URI objects.
If objects are passed in, none of the passed objects will be modified.
\Zend\Uri\Uristring
\Zend\Uri\Uristring
normalize() : \Zend\Uri\Uri
Normalizing a URI includes removing any redundant parent directory or current directory references from the path (e.g. foo/bar/../baz becomes foo/baz), normalizing the scheme case, decoding any over-encoded characters etc.
Eventually, two normalized URLs pointing to the same resource should be equal even if they were originally represented by two different strings
parseScheme(string $uriString) : string | null
This is used by the parse() method, but is useful as a standalone public method if one wants to test a URI string for it's scheme before doing anything with it.
Will return the scheme if found, or NULL if no scheme found (URI may still be valid, but not full)
string
\Zend\Uri\Exception\InvalidArgumentException |
|---|
stringnull
removePathDotSegments(string $path) : string
./, /./) from a path
Algorithm is adapted from RFC-3986 section 5.2.4 (@link http://tools.ietf.org/html/rfc3986#section-5.2.4)
| todo | consider optimizing |
|---|
string
stringresolve(\Zend\Uri\Uri | string $baseUri) : \Zend\Uri\Uri
This is similar to merge() - only it uses the supplied URI as the base reference instead of using the current URI as the base reference.
Merging algorithm is adapted from RFC-3986 section 5.2 (@link http://tools.ietf.org/html/rfc3986#section-5.2)
\Zend\Uri\Uristring
\Zend\Uri\Exception\InvalidArgumentException |
|---|
setEscaper(\Zend\Escaper\Escaper $escaper)
\Zend\Escaper\Escaper
setFragment(string $fragment) : \Zend\Uri\Uri
string
\Zend\Uri\Exception\InvalidUriPartException |
If the schema definition does not have this part |
|---|
setHost(string $host) : \Zend\Uri\Uri
Note that the generic syntax for URIs allows using host names which are not necessarily IPv4 addresses or valid DNS host names. For example, IPv6 addresses are allowed as well, and also an abstract "registered name" which may be any name composed of a valid set of characters, including, for example, tilda (~) and underscore (_) which are not allowed in DNS names.
Subclasses of Uri may impose more strict validation of host names - for example the HTTP RFC clearly states that only IPv4 and valid DNS names are allowed in HTTP URIs.
string
\Zend\Uri\Exception\InvalidUriPartException |
|---|
setQuery(string | array $query) : \Zend\Uri\Uri
If an array is provided, will encode this array of parameters into a query string. Array values will be represented in the query string using PHP's common square bracket notation.
stringarray
setScheme(string $scheme) : \Zend\Uri\Uri
If the scheme is not valid according to the generic scheme syntax or is not acceptable by the specific URI class (e.g. 'http' or 'https' are the only acceptable schemes for the Zend\Uri\Http class) an exception will be thrown.
You can check if a scheme is valid before setting it using the validateScheme() method.
string
\Zend\Uri\Exception\InvalidUriPartException |
|---|
setUserInfo(string $userInfo) : \Zend\Uri\Uri
string
\Zend\Uri\Exception\InvalidUriPartException |
If the schema definition does not have this part |
|---|
toString() : string
validateHost(string $host, int $allowed) : bool
Users may control which host types to allow by passing a second parameter with a bitmask of HOST_* constants which are allowed. If not specified, all address types will be allowed.
Note that the generic URI syntax allows different host representations, including IPv4 addresses, IPv6 addresses and future IP address formats enclosed in square brackets, and registered names which may be DNS names or even more complex names. This is different (and is much more loose) from what is commonly accepted as valid HTTP URLs for example.
string
intbitmask of allowed host types
boolvalidatePath(string $path) : bool
string
boolvalidatePort(int $port) : bool
Valid values include numbers between 1 and 65535, and empty values
int
boolvalidateQueryFragment(string $input) : bool
Query and Fragment parts are both restricted by the same syntax rules, so the same validation method can be used for both.
You can encode a query or fragment part to ensure it is valid by passing it through the encodeQueryFragment() method.
string
boolvalidateScheme(string $scheme) : bool
Will check $scheme to be valid against the generic scheme syntax defined in RFC-3986. If the class also defines specific acceptable schemes, will also check that $scheme is one of them.
string
boolvalidateUserInfo(string $userInfo) : bool
string
booldecodeUrlEncodedChars(string $input, string $allowed) : mixed
Will not decode any characters which are not listed in the 'allowed' list
string
stringPattern of allowed characters
mixedisValidDnsHostname(string $host) : bool
string
boolisValidIpAddress(string $host, int $allowed) : bool
string
intallowed address types
boolisValidRegName(string $host) : bool
string
boolnormalizeFragment(string $fragment) : string
Currently this is exactly the same as normalizeQuery().
string
stringnormalizeHost(string $host) : string
By default this converts host names to lower case
string
stringnormalizePath(string $path) : string
This involves removing redundant dot segments, decoding any over-encoded characters and encoding everything that needs to be encoded and is not
string
stringnormalizePort(int $port, string $scheme) : int | null
If the class defines a default port for the current scheme, and the current port is default, it will be unset.
int
string
intnull
normalizeQuery(string $query) : string
This involves decoding everything that doesn't need to be encoded, and encoding everything else
string
stringnormalizeScheme(string $scheme) : string
Usually this means simply converting the scheme to lower case
string
stringreset()
$defaultPorts : array
Inheriting URI classes may set this, and the normalization methods will automatically remove the port if it is equal to the default port for the current scheme
$fragment : string
$host : string
$path : string
$port : int
$query : string
$scheme : string
$userInfo : string
$validHostTypes : int
$validSchemes : array
Subclasses of this class that only accept specific schemes may set the list of accepted schemes here. If not empty, when setScheme() is called it will only accept the schemes listed here.
CHAR_GEN_DELIMS
CHAR_QUERY_DELIMS
CHAR_RESERVED
CHAR_SUB_DELIMS
CHAR_UNRESERVED
HOST_ALL
HOST_DNS
HOST_DNS_OR_IPV4
HOST_DNS_OR_IPV4_OR_IPV6
HOST_DNS_OR_IPV4_OR_IPV6_OR_REGNAME
HOST_DNS_OR_IPV6
HOST_DNS_OR_IPVANY
HOST_IPV4
Finally use a hexadecimal representation.
HOST_IPV6
HOST_IPVANY
HOST_IPVFUTURE
HOST_REGNAME