Uri

Extends \Joomla\Uri\Uri

JUri Class

This class serves two purposes. First it parses a URI and provides a common interface for the Joomla Platform to access and manipulate a URI. Second it obtains the URI of the current executing script from the server regardless of server.

since

1.7.0

Methods

__construct

Constructor.

__construct(string $uri = null) 
inherited

You can pass a URI string to the constructor to initialise a specific URI.

since

1.0

Arguments

$uri

stringThe optional URI string

__toString

Magic method to get the string representation of the URI object.

__toString() : string
inherited
since

1.0

Response

string

_cleanPath

Resolves //, .

_cleanPath(string $path) : string
deprecated

./ and ./ from a path and returns the result. Eg:

/foo/bar/../boo.php => /foo/boo.php /foo/bar/../../boo.php => /boo.php /foo/bar/.././/boo.php => /foo/boo.php

since

1.7.0

deprecated

4.0 Use {@link \Joomla\Uri\Uri::cleanPath()} instead

Arguments

$path

stringThe URI path to clean.

Response

stringCleaned and resolved URI path.

base

Returns the base URI for the request.

base(boolean $pathonly = false) : string
static
since

1.7.0

Arguments

$pathonly

booleanIf false, prepend the scheme, host and port information. Default is false.

Response

stringThe base URI string

buildQuery

Build a query from an array (reverse of the PHP parse_str()).

buildQuery(array $params) : string
inherited static
see \Joomla\Uri\parse_str()
since

1.0

Arguments

$params

arrayThe array of key => value pairs to return as a query string.

Response

stringThe resulting query string.

cleanPath

Resolves //, .

cleanPath(string $path) : string
inherited

./ and ./ from a path and returns the result. Eg:

/foo/bar/../boo.php => /foo/boo.php /foo/bar/../../boo.php => /boo.php /foo/bar/.././/boo.php => /foo/boo.php

since

1.0

Arguments

$path

stringThe URI path to clean.

Response

stringCleaned and resolved URI path.

current

Returns the URL for the request, minus the query.

current() : string
static
since

1.7.0

Response

string

delVar

Removes an item from the query string variables if it exists.

delVar(string $name) : void
since

1.0

Arguments

$name

stringName of variable to remove.

getFragment

Get the URI anchor string Everything after the "#".

getFragment() : string
inherited
since

1.0

Response

stringThe URI anchor string.

getHost

Get URI host Returns the hostname/ip or null if no hostname/ip was specified.

getHost() : string
inherited
since

1.0

Response

stringThe URI host.

getInstance

Returns the global JUri object, only creating it if it doesn't already exist.

getInstance(string $uri = 'SERVER') : \Joomla\CMS\Uri\Uri
static
since

1.7.0

Arguments

$uri

stringThe URI to parse. [optional: if null uses script URI]

Response

\Joomla\CMS\Uri\UriThe URI object.

getPass

Get URI password Returns the password, or null if no password was specified.

getPass() : string
inherited
since

1.0

Response

stringThe URI password.

getPath

Gets the URI path string.

getPath() : string
inherited
since

1.0

Response

stringThe URI path string.

getPort

Get URI port Returns the port number, or null if no port was specified.

getPort() : integer
inherited
since

1.0

Response

integerThe URI port number.

getQuery

Returns flat query string.

getQuery(boolean $toArray = false) : string|array
inherited
since

1.0

Arguments

$toArray

booleanTrue to return the query as a key => value pair array.

Response

string|arrayQuery string or Array of parts in query string depending on the function param

getScheme

Get URI scheme (protocol) ie. http, https, ftp, etc.

getScheme() : string
inherited

..

since

1.0

Response

stringThe URI scheme.

getUser

Get URI username Returns the username, or null if no username was specified.

getUser() : string
inherited
since

1.0

Response

stringThe URI username.

getVar

Returns a query variable by name.

getVar(string $name, string $default = null) : mixed
inherited
since

1.0

Arguments

$name

stringName of the query variable to get.

$default

stringDefault value to return if the variable is not set.

Response

mixedValue of the specified query variable.

hasVar

Checks if variable exists.

hasVar(string $name) : boolean
inherited
since

1.0

Arguments

$name

stringName of the query variable to check.

Response

booleanTrue if the variable exists.

isInternal

Checks if the supplied URL is internal

isInternal(string $url) : boolean
static
since

1.7.0

Arguments

$url

stringThe URL to check.

Response

booleanTrue if Internal.

isSsl

Checks whether the current URI is using HTTPS.

isSsl() : boolean
inherited
since

1.0

Response

booleanTrue if using SSL via HTTPS.

parse

Parse a given URI and populate the class fields.

parse(string $uri) : boolean
inherited
since

1.0

Arguments

$uri

stringThe URI string to parse.

Response

booleanTrue on success.

render

Returns full uri string.

render(integer $parts = self::ALL) : string
inherited
since

1.2.0

Arguments

$parts

integerA bitmask specifying the parts to render.

Response

stringThe rendered URI string.

reset

Method to reset class static members for testing and other various issues.

reset() : void
static
since

1.7.0

root

Returns the root URI for the request.

root(boolean $pathonly = false, string $path = null) : string
static
since

1.7.0

Arguments

$pathonly

booleanIf false, prepend the scheme, host and port information. Default is false.

$path

stringThe path

Response

stringThe root URI string.

setFragment

Set the URI anchor string everything after the "#".

setFragment(string $anchor) : void
since

1.0

Arguments

$anchor

stringThe URI anchor string.

setHost

Set URI host.

setHost(string $host) : void
since

1.0

Arguments

$host

stringThe URI host.

setPass

Set URI password.

setPass(string $pass) : void
since

1.0

Arguments

$pass

stringThe URI password.

setPath

Set the URI path string.

setPath(string $path) : void
since

1.0

Arguments

$path

stringThe URI path string.

setPort

Set URI port.

setPort(integer $port) : void
since

1.0

Arguments

$port

integerThe URI port number.

setQuery

Sets the query to a supplied string in format: foo=bar&x=y

setQuery(mixed $query) : void
since

1.0

Arguments

$query

mixedThe query string or array.

setScheme

Set URI scheme (protocol) ie. http, https, ftp, etc.

setScheme(string $scheme) : void

..

since

1.0

Arguments

$scheme

stringThe URI scheme.

setUser

Set URI username.

setUser(string $user) : void
since

1.0

Arguments

$user

stringThe URI username.

setVar

Adds a query variable and value, replacing the value if it already exists and returning the old value.

setVar(string $name, string $value) : string
since

1.0

Arguments

$name

stringName of the query variable to set.

$value

stringValue of the query variable.

Response

stringPrevious value for the query variable.

toString

Returns full uri string.

toString(array $parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')) : string
inherited
since

1.0

Arguments

$parts

arrayAn array of strings specifying the parts to render.

Response

stringThe rendered URI string.

Properties

instances

An array of JUri instances.

static
since

1.7.0

Type(s)

array<mixed,\Joomla\CMS\Uri\Uri>

base

The current calculated base url segments.

static
since

1.7.0

Type(s)

array

root

The current calculated root url segments.

static
since

1.7.0

Type(s)

array

current

The current url.

static
since

1.7.0

Type(s)

string

uri

Original URI

inherited
since

1.0

Type(s)

string

scheme

Protocol

inherited
since

1.0

Type(s)

string

host

Host

inherited
since

1.0

Type(s)

string

port

Port

inherited
since

1.0

Type(s)

integer

user

Username

inherited
since

1.0

Type(s)

string

pass

Password

inherited
since

1.0

Type(s)

string

path

Path

inherited
since

1.0

Type(s)

string

query

Query

inherited
since

1.0

Type(s)

string

fragment

Anchor

inherited
since

1.0

Type(s)

string

vars

Query variable hash

inherited
since

1.0

Type(s)

array