Documentation

Url
in package

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

Table of Contents

Properties

$fragment  : mixed
$host  : mixed
$password  : mixed
$path  : mixed
$port  : mixed
$query  : QueryString
$scheme  : mixed
$username  : mixed

Methods

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

Properties

$fragment

protected mixed $fragment

$host

protected mixed $host

$password

protected mixed $password

$path

protected mixed $path = ''

$port

protected mixed $port

$scheme

protected mixed $scheme

$username

protected mixed $username

Methods

__clone()

Clone the URL

public __clone() : mixed

__construct()

Create a new URL from URL parts

public __construct(string $scheme, string $host[, string $username = null ][, string $password = null ][, int $port = null ][, string $path = null ][, QueryString|array<string|int, mixed>|string $query = null ][, string $fragment = null ]) : mixed
Parameters
$scheme : string

Scheme of the URL

$host : string

Host of the URL

$username : string = null

Username of the URL

$password : string = null

Password of the URL

$port : int = null

Port of the URL

$path : string = null

Path of the URL

$query : QueryString|array<string|int, mixed>|string = null

Query string of the URL

$fragment : string = null

Fragment of the URL

__toString()

Returns the URL as a URL string

public __toString() : string
Return values
string

addPath()

Add a relative path to the currently set path.

public addPath(string $relativePath) : Url
Parameters
$relativePath : string

Relative path to add

Return values
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.

public static buildUrl(array<string|int, mixed> $parts) : string
Parameters
$parts : array<string|int, mixed>

Array of parse_url parts

Return values
string

combine()

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

public combine(string $url[, bool $strictRfc3986 = false ]) : Url
Parameters
$url : string

Relative URL to combine with

$strictRfc3986 : bool = false

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

Tags
throws
InvalidArgumentException
link
http://tools.ietf.org/html/rfc3986#section-5.4
Return values
Url

factory()

Factory method to create a new URL from a URL string

public static factory(string $url) : Url
Parameters
$url : string

Full URL used to create a Url object

Tags
throws
InvalidArgumentException
Return values
Url

getFragment()

Get the fragment part of the URL

public getFragment() : null|string
Return values
null|string

getHost()

Get the host part of the URL

public getHost() : string
Return values
string

getParts()

Get the parts of the URL as an array

public getParts() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPassword()

Get the password part of the URL

public getPassword() : null|string
Return values
null|string

getPath()

Get the path part of the URL

public getPath() : string
Return values
string

getPathSegments()

Get the path segments of the URL as an array

public getPathSegments() : array<string|int, mixed>
Return values
array<string|int, mixed>

getPort()

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

public getPort() : int|null
Return values
int|null

getScheme()

Get the scheme part of the URL

public getScheme() : string
Return values
string

getUsername()

Get the username part of the URl

public getUsername() : null|string
Return values
null|string

isAbsolute()

Check if this is an absolute URL

public isAbsolute() : bool
Return values
bool

normalizePath()

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

public normalizePath() : Url
Return values
Url

setFragment()

Set the fragment part of the URL

public setFragment(string $fragment) : Url
Parameters
$fragment : string

Fragment to set

Return values
Url

setHost()

Set the host of the request.

public setHost(string $host) : Url
Parameters
$host : string

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

Return values
Url

setPassword()

Set the password part of the URL

public setPassword(string $password) : Url
Parameters
$password : string

Password to set

Return values
Url

setPath()

Set the path part of the URL

public setPath(array<string|int, mixed>|string $path) : Url
Parameters
$path : array<string|int, mixed>|string

Path string or array of path segments

Return values
Url

setPort()

Set the port part of the URL

public setPort(int $port) : Url
Parameters
$port : int

Port to set

Return values
Url

setQuery()

Set the query part of the URL

public setQuery(QueryString|string|array<string|int, mixed> $query) : Url
Parameters
$query : QueryString|string|array<string|int, mixed>

Query to set

Return values
Url

setScheme()

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

public setScheme(string $scheme) : Url
Parameters
$scheme : string

Scheme to set

Return values
Url

setUsername()

Set the username part of the URL

public setUsername(string $username) : Url
Parameters
$username : string

Username to set

Return values
Url

        
On this page

Search results