Documentation for crwlr / url (v0.1)

Attention: You're currently viewing the documentation for v0.1 of the url package.
This is not the latest version of the package.
If you didn't navigate to this version intentionally, you can click here to switch to the latest version.

All Available Url Components

Below is a list of all components the Url class takes care of. The highlighted part in the example url shows what the component returns.

scheme

https ://john:123@subdomain.example.com:8080/foo?bar=baz#anchor

user

https:// john :123@subdomain.example.com:8080/foo?bar=baz#anchor

pass (or password = alias of pass)

https://john: 123 @subdomain.example.com:8080/foo?bar=baz#anchor

host

https://john:123@ subdomain.example.com :8080/foo?bar=baz#anchor

domain

https://john:123@subdomain. example.com :8080/foo?bar=baz#anchor

domainLabel

https://john:123@subdomain. example .com:8080/foo?bar=baz#anchor

domainSuffix

https://john:123@subdomain.example. com :8080/foo?bar=baz#anchor

subdomain

https://john:123@ subdomain .example.com:8080/foo?bar=baz#anchor

port

https://john:123@subdomain.example.com: 8080 /foo?bar=baz#anchor

path

https://john:123@subdomain.example.com:8080 /foo ?bar=baz#anchor

query

https://john:123@subdomain.example.com:8080/foo? bar=baz #anchor

fragment

https://john:123@subdomain.example.com:8080/foo?bar=baz# anchor

When a component is not present in a url (e.g. it doesn't contain user and password) the corresponding properties will return NULL.

Combinations of components

root

There are situations where it can be very helpful to get the root as it's called here. It returns everything that comes before the path component.

$url = Url::parse('https://www.example.com:8080/foo?bar=baz');
$root = $url->root();   // => "https://www.example.com:8080"

relative

Complementary to the root you can also retrieve all components starting from the path (path, query and fragment) combined, via the relative property. It's called relative because it's like a relative url (without scheme and host information).

$url = Url::parse('https://www.example.com/foo?bar=baz#anchor');
$relative = $url->relative();   // => "/foo?bar=baz#anchor"