Zend Framework  3.0
Public Member Functions | List of all members
UriInterface Interface Reference

Interface defining a URI. More...

Public Member Functions

 __construct ($uri=null)
 Create a new URI object.
 
 isValid ()
 Check if the URI is valid.
 
 isValidRelative ()
 Check if the URI is a valid relative URI.
 
 isAbsolute ()
 Check if the URI is an absolute or relative URI.
 
 parse ($uri)
 Parse a URI string.
 
 toString ()
 Compose the URI into a string.
 
 normalize ()
 Normalize the URI.
 
 makeRelative ($baseUri)
 Convert the link to a relative link by substracting a base URI.
 
 getScheme ()
 Get the scheme part of the URI.
 
 getUserInfo ()
 Get the User-info (usually user:password) part.
 
 getHost ()
 Get the URI host.
 
 getPort ()
 Get the URI port.
 
 getPath ()
 Get the URI path.
 
 getQuery ()
 Get the URI query.
 
 getQueryAsArray ()
 Return the query string as an associative array of key => value pairs.
 
 getFragment ()
 Get the URI fragment.
 
 setScheme ($scheme)
 Set the URI scheme.
 
 setUserInfo ($userInfo)
 Set the URI User-info part (usually user:password)
 
 setHost ($host)
 Set the URI host.
 
 setPort ($port)
 Set the port part of the URI.
 
 setPath ($path)
 Set the path.
 
 setQuery ($query)
 Set the query string.
 
 setFragment ($fragment)
 Set the URI fragment part.
 
 __toString ()
 Magic method to convert the URI to a string.
 

Detailed Description

Interface defining a URI.

Constructor & Destructor Documentation

__construct (   $uri = null)

Create a new URI object.

Parameters
Uri | string | null$uri
Exceptions
Exception\InvalidArgumentException

Implemented in Uri.

Member Function Documentation

__toString ( )

Magic method to convert the URI to a string.

Returns
string

Implemented in Uri.

getFragment ( )

Get the URI fragment.

Returns
string|null

Implemented in Uri.

getHost ( )

Get the URI host.

Returns
string|null

Implemented in Uri.

getPath ( )

Get the URI path.

Returns
string|null

Implemented in Uri.

getPort ( )

Get the URI port.

Returns
int|null

Implemented in Uri, and Http.

getQuery ( )

Get the URI query.

Returns
string|null

Implemented in Uri.

getQueryAsArray ( )

Return the query string as an associative array of key => value pairs.

This is an extension to RFC-3986 but is quite useful when working with most common URI types

Returns
array

Implemented in Uri.

getScheme ( )

Get the scheme part of the URI.

Returns
string|null

Implemented in Uri.

getUserInfo ( )

Get the User-info (usually user:password) part.

Returns
string|null

Implemented in Uri, and Http.

isAbsolute ( )

Check if the URI is an absolute or relative URI.

Returns
bool

Implemented in Uri.

isValid ( )

Check if the URI is valid.

Note that a relative URI may still be valid

Returns
bool

Implemented in Uri, Mailto, and File.

isValidRelative ( )

Check if the URI is a valid relative URI.

Returns
bool

Implemented in Uri.

makeRelative (   $baseUri)

Convert the link to a relative link by substracting a base 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.

Parameters
Uri | string$baseUri
Returns
Uri

Implemented in Uri.

normalize ( )

Normalize the 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

Returns
Uri

Implemented in Uri.

parse (   $uri)

Parse a URI string.

Parameters
string$uri
Returns
Uri

Implemented in Uri, and Http.

setFragment (   $fragment)

Set the URI fragment part.

Parameters
string$fragment
Returns
Uri
Exceptions
Exception\InvalidUriPartExceptionIf the schema definition does not have this part

Implemented in Uri, and File.

setHost (   $host)

Set the URI host.

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.

Parameters
string$host
Exceptions
Exception\InvalidUriPartException
Returns
Uri

Implemented in Uri.

setPath (   $path)

Set the path.

Parameters
string$path
Returns
Uri

Implemented in Uri.

setPort (   $port)

Set the port part of the URI.

Parameters
int$port
Returns
Uri

Implemented in Uri.

setQuery (   $query)

Set the query string.

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.

Parameters
string | array$query
Returns
Uri

Implemented in Uri.

setScheme (   $scheme)

Set the URI scheme.

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 class) an exception will be thrown.

You can check if a scheme is valid before setting it using the validateScheme() method.

Parameters
string$scheme
Exceptions
Exception\InvalidUriPartException
Returns
Uri

Implemented in Uri.

setUserInfo (   $userInfo)

Set the URI User-info part (usually user:password)

Parameters
string$userInfo
Returns
Uri
Exceptions
Exception\InvalidUriPartExceptionIf the schema definition does not have this part

Implemented in Uri, Http, and File.

toString ( )

Compose the URI into a string.

Returns
string
Exceptions
Exception\InvalidUriException

Implemented in Uri.