Class Guzzle\Http\Url

InheritanceGuzzle\Http\Url

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

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__clone() Clone the URL Guzzle\Http\Url
__construct() Create a new URL from URL parts Guzzle\Http\Url
__toString() Returns the URL as a URL string Guzzle\Http\Url
addPath() Add a relative path to the currently set path. Guzzle\Http\Url
buildUrl() Build a URL from parse_url parts. The generated URL will be a relative URL if a scheme or host are not provided. Guzzle\Http\Url
combine() Combine the URL with another URL. Follows the rules specific in RFC 3986 section 5.4. Guzzle\Http\Url
factory() Factory method to create a new URL from a URL string Guzzle\Http\Url
getFragment() Get the fragment part of the URL Guzzle\Http\Url
getHost() Get the host part of the URL Guzzle\Http\Url
getParts() Get the parts of the URL as an array Guzzle\Http\Url
getPassword() Get the password part of the URL Guzzle\Http\Url
getPath() Get the path part of the URL Guzzle\Http\Url
getPathSegments() Get the path segments of the URL as an array Guzzle\Http\Url
getPort() Get the port part of the URl. Will return the default port for a given scheme if no port has been set. Guzzle\Http\Url
getQuery() Get the query part of the URL as a QueryString object Guzzle\Http\Url
getScheme() Get the scheme part of the URL Guzzle\Http\Url
getUsername() Get the username part of the URl Guzzle\Http\Url
isAbsolute() Check if this is an absolute URL Guzzle\Http\Url
normalizePath() Normalize the URL so that double slashes and relative paths are removed Guzzle\Http\Url
setFragment() Set the fragment part of the URL Guzzle\Http\Url
setHost() Set the host of the request. Guzzle\Http\Url
setPassword() Set the password part of the URL Guzzle\Http\Url
setPath() Set the path part of the URL Guzzle\Http\Url
setPort() Set the port part of the URL Guzzle\Http\Url
setQuery() Set the query part of the URL Guzzle\Http\Url
setScheme() Set the scheme part of the URL (http, https, ftp, etc) Guzzle\Http\Url
setUsername() Set the username part of the URL Guzzle\Http\Url

Property Details

$fragment protected property
protected $fragment null
$host protected property
protected $host null
$password protected property
protected $password null
$path protected property
protected $path ''
$port protected property
protected $port null
$query protected property

Query part of the URL

$scheme protected property
protected $scheme null
$username protected property
protected $username null

Method Details

__clone() public method

Clone the URL

public void __clone ( )
__construct() public method

Create a new URL from URL parts

public void __construct ( $scheme, $host, $username null, $password null, $port null, $path null, Guzzle\Http\QueryString $query null, $fragment null )
$scheme string

Scheme of the URL

$host string

Host of the URL

$username string

Username of the URL

$password string

Password of the URL

$port int

Port of the URL

$path string

Path of the URL

$query Guzzle\Http\QueryString|array|string

Query string of the URL

$fragment string

Fragment of the URL

__toString() public method

Returns the URL as a URL string

public string __toString ( )
addPath() public method

Add a relative path to the currently set path.

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

Relative path to add

buildUrl() public static method

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 string buildUrl ( array $parts )
$parts array

Array of parse_url parts

combine() public method

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

public Guzzle\Http\Url combine ( $url, $strictRfc3986 false )
$url string

Relative URL to combine with

$strictRfc3986 bool

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
factory() public static method

Factory method to create a new URL from a URL string

public static Guzzle\Http\Url factory ( $url )
$url string

Full URL used to create a Url object

throws Guzzle\Common\Exception\InvalidArgumentException
getFragment() public method

Get the fragment part of the URL

public null|string getFragment ( )
getHost() public method

Get the host part of the URL

public string getHost ( )
getParts() public method

Get the parts of the URL as an array

public array getParts ( )
getPassword() public method

Get the password part of the URL

public null|string getPassword ( )
getPath() public method

Get the path part of the URL

public string getPath ( )
getPathSegments() public method

Get the path segments of the URL as an array

public array getPathSegments ( )
getPort() public method

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

public int|null getPort ( )
getQuery() public method

Get the query part of the URL as a QueryString object

public Guzzle\Http\QueryString getQuery ( )
getScheme() public method

Get the scheme part of the URL

public string getScheme ( )
getUsername() public method

Get the username part of the URl

public null|string getUsername ( )
isAbsolute() public method

Check if this is an absolute URL

public bool isAbsolute ( )
normalizePath() public method

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

public Guzzle\Http\Url normalizePath ( )
setFragment() public method

Set the fragment part of the URL

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

Fragment to set

setHost() public method

Set the host of the request.

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

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

setPassword() public method

Set the password part of the URL

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

Password to set

setPath() public method

Set the path part of the URL

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

Path string or array of path segments

setPort() public method

Set the port part of the URL

public Guzzle\Http\Url setPort ( $port )
$port int

Port to set

setQuery() public method

Set the query part of the URL

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

Query to set

setScheme() public method

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

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

Scheme to set

setUsername() public method

Set the username part of the URL

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

Username to set