\Guzzle\HttpUrl

Parses and generates URLs based on URL parts. In favor of performance, URL parts are not validated.

Summary

Methods
Properties
Constants
factory()
buildUrl()
__construct()
__clone()
__toString()
getParts()
setHost()
getHost()
setScheme()
getScheme()
setPort()
getPort()
setPath()
normalizePath()
addPath()
getPath()
getPathSegments()
setPassword()
getPassword()
setUsername()
getUsername()
getQuery()
setQuery()
getFragment()
setFragment()
isAbsolute()
combine()
No public properties found
No constants found
No protected methods found
$scheme
$host
$port
$username
$password
$path
$fragment
$query
N/A
addQuery()
No private properties found
N/A

Properties

$scheme

$scheme : 

Type

$host

$host : 

Type

$port

$port : 

Type

$username

$username : 

Type

$password

$password : 

Type

$path

$path : 

Type

$fragment

$fragment : 

Type

Methods

factory()

factory(string  $url) : \Guzzle\Http\Url

Factory method to create a new URL from a URL string

Parameters

string $url

Full URL used to create a Url object

Throws

\Guzzle\Common\Exception\InvalidArgumentException

Returns

\Guzzle\Http\Url

buildUrl()

buildUrl(array  $parts) : string

Build a URL from parse_url parts. The generated URL will be a relative URL if a scheme or host are not provided.

Parameters

array $parts

Array of parse_url parts

Returns

string

__construct()

__construct(string  $scheme, string  $host, string  $username = null, string  $password = null, integer  $port = null, string  $path = null, \Guzzle\Http\QueryString|array|string  $query = null, string  $fragment = null) 

Create a new URL from URL parts

Parameters

string $scheme

Scheme of the URL

string $host

Host of the URL

string $username

Username of the URL

string $password

Password of the URL

integer $port

Port of the URL

string $path

Path of the URL

\Guzzle\Http\QueryString|array|string $query

Query string of the URL

string $fragment

Fragment of the URL

__clone()

__clone() 

Clone the URL

__toString()

__toString() : string

Returns the URL as a URL string

Returns

string

getParts()

getParts() : array

Get the parts of the URL as an array

Returns

array

setHost()

setHost(string  $host) : \Guzzle\Http\Url

Set the host of the request.

Parameters

string $host

Host to set (e.g. www.yahoo.com, yahoo.com)

Returns

\Guzzle\Http\Url

getHost()

getHost() : string

Get the host part of the URL

Returns

string

setScheme()

setScheme(string  $scheme) : \Guzzle\Http\Url

Set the scheme part of the URL (http, https, ftp, etc)

Parameters

string $scheme

Scheme to set

Returns

\Guzzle\Http\Url

getScheme()

getScheme() : string

Get the scheme part of the URL

Returns

string

setPort()

setPort(integer  $port) : \Guzzle\Http\Url

Set the port part of the URL

Parameters

integer $port

Port to set

Returns

\Guzzle\Http\Url

getPort()

getPort() : integer|null

Get the port part of the URl. Will return the default port for a given scheme if no port has been set.

Returns

integer|null

setPath()

setPath(array|string  $path) : \Guzzle\Http\Url

Set the path part of the URL

Parameters

array|string $path

Path string or array of path segments

Returns

\Guzzle\Http\Url

normalizePath()

normalizePath() : \Guzzle\Http\Url

Normalize the URL so that double slashes and relative paths are removed

Returns

\Guzzle\Http\Url

addPath()

addPath(string  $relativePath) : \Guzzle\Http\Url

Add a relative path to the currently set path.

Parameters

string $relativePath

Relative path to add

Returns

\Guzzle\Http\Url

getPath()

getPath() : string

Get the path part of the URL

Returns

string

getPathSegments()

getPathSegments() : array

Get the path segments of the URL as an array

Returns

array

setPassword()

setPassword(string  $password) : \Guzzle\Http\Url

Set the password part of the URL

Parameters

string $password

Password to set

Returns

\Guzzle\Http\Url

getPassword()

getPassword() : null|string

Get the password part of the URL

Returns

null|string

setUsername()

setUsername(string  $username) : \Guzzle\Http\Url

Set the username part of the URL

Parameters

string $username

Username to set

Returns

\Guzzle\Http\Url

getUsername()

getUsername() : null|string

Get the username part of the URl

Returns

null|string

getQuery()

getQuery() : \Guzzle\Http\QueryString

Get the query part of the URL as a QueryString object

Returns

\Guzzle\Http\QueryString

setQuery()

setQuery(\Guzzle\Http\QueryString|string|array  $query) : \Guzzle\Http\Url

Set the query part of the URL

Parameters

\Guzzle\Http\QueryString|string|array $query

Query to set

Returns

\Guzzle\Http\Url

getFragment()

getFragment() : null|string

Get the fragment part of the URL

Returns

null|string

setFragment()

setFragment(string  $fragment) : \Guzzle\Http\Url

Set the fragment part of the URL

Parameters

string $fragment

Fragment to set

Returns

\Guzzle\Http\Url

isAbsolute()

isAbsolute() : boolean

Check if this is an absolute URL

Returns

boolean

combine()

combine(string  $url, boolean  $strictRfc3986 = false) : \Guzzle\Http\Url

Combine the URL with another URL. Follows the rules specific in RFC 3986 section 5.4.

Parameters

string $url

Relative URL to combine with

boolean $strictRfc3986

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".

Throws

\Guzzle\Common\Exception\InvalidArgumentException

Returns

\Guzzle\Http\Url

addQuery()

addQuery(\Guzzle\Http\QueryString  $new,   $strictRfc386) 

Parameters

\Guzzle\Http\QueryString $new
$strictRfc386