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.


https ://


https:// john

pass (or password = alias of pass)

https://john: 123


https://john:123@ :8080/foo?bar=baz#anchor


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


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


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


https://john:123@ subdomain

port 8080 /foo?bar=baz#anchor

path /foo ?bar=baz#anchor

query bar=baz #anchor

fragment 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


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('');
$root = $url->root();   // => ""


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('');
$relative = $url->relative();   // => "/foo?bar=baz#anchor"