library url
Url is a small PHP class that helps dealing with Urls.
arne-groskurth/url
Url is a small PHP class that helps dealing with Urls.
- Wednesday, February 28, 2018
- by arnegroskurth
- Repository
- 1 Watchers
- 2 Stars
- 4,238 Installations
- PHP
- 1 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 3 Versions
- 12 % Grown
Url
, (*1)
Url is a small PHP class that helps dealing with Urls., (*2)
Setup
$ composer require arne-groskurth/url
Examples
<?php
use ArneGroskurth\Url\Url;
// construct url
$url = new Url();
$url->setHost('domain.tld');
$url->setScheme('ftps');
// parses given url
$url = new Url('http://username:password@www.test.com:8080/some/path.html?one=1&two=2#myfrag');
// modify parts
$url->setPort(80);
$url->removeQueryParameter('two');
$url->setQueryParameter('three', 3);
// get back url string
print $url->getUrl();
// avoid some parts on return
print $url->getUrl(Url::ALL - Url::CREDENTIALS);
print $url->getUrl(Url::SCHEME + Url::PORT);
// interpret link relative to some url
print $url->resolveRelativeUrl('../other/path.html')->getUrl();
print $url->resolveRelativeUrl('//domain.tld/')->getUrl();