This package is abandoned and no longer maintained. No replacement package was suggested.

Url is a small PHP class that helps dealing with Urls.

v1.1.0 2018-02-28 15:02 UTC

This package is not auto-updated.

Last update: 2021-10-30 04:05:52 UTC


README

Build Status codecov License

Url is a small PHP class that helps dealing with Urls.

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();