Skip to content

url

109 1 1 MIT
v2.2.0 (6 Jan 2026) Apr 15 2018 133 (month)

url is a package for working, modifying and parsing web URLs. This package is for you when PHP's parse_url() is not enough.

Key Features:

  • Parse a URL and access or modify all its components separately.
  • Resolve any relative reference you may find in an HTML document to an absolute URL, based on the document's URL.
  • Get not only the full host of a URL, but also the registrable domain, the domain suffix and the subdomain parts of the host separately (Thanks to the Mozilla Public Suffix List).
  • An advanced API to access and manipulate the URL query component.
  • Compare URLs or components of URLs (e.g. checking if different URLs point to the same host or domain)
  • Thanks to symfony/polyfill-intl-idn it's also no problem to parse internationalized domain names (IDN).
  • Includes an adapter class which implements the PSR-7 UriInterface.

Example Use


<?php
use Crwlr\Url;

$url = new Url('https://www.example.com/path?query=value#fragment');

// Parse url for parts:
echo $url->scheme();
echo $url->host();
echo $url->path();
echo $url->query();
echo $url->fragment();
// update values
echo $url->path("some/new/query");


// Create url from parts:
$url = new Url();
$url->scheme('https');
$url->host('www.example.com');
$url->path('/path');
$url->query('query=value');
$url->fragment('fragment');
echo $url->toString();

Alternatives / Similar


Other Languages

636 10.7.7 (2026-11-28 00:20:29 ago) May 05 2015 compare
1,333 0.9.0 (2026-10-09 19:53:47 ago) Dec 28 2012 compare
6,919 10.0.0 (2026-10-21 12:25:29 ago) Nov 13 2013 compare
ip
1,542 2.0.1 (2025-10-13 17:09:54 ago) Aug 15 2012 compare
1,512 1.3.3 (2026-07-03 19:48:56 ago) Feb 14 2011 compare
6,214 0.1.3 (2022-06-28 06:09:19 ago) Jun 18 2013 compare
Was this page helpful?