This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

URL parser for PHP, allow you to extract every piece of information of a URL/HOST, structured and clean.

v1.0.0 2013-11-25 07:24 UTC

This package is auto-updated.

Last update: 2021-09-27 07:15:48 UTC



MXUrlParser is capable of parsing a complete URL and extract some parts of it like the URL parts (using php parse_url() function) and some domain name parts (using Mozilla public suffix list).

Available parts are (Assuming URL is

  • scheme: https
  • host:
  • path: /1/2/3
  • query: key=val
  • fragment: anchor
  • subdomain: dev
  • domain: api.example
  • tld:


  • PHP >= 5.3

How to download

There are several ways to download MxUrlParser-PHP:

  • Install with composer ("max13/url-parser": "dev-master")
  • Clone the github repository with git clone <repo> [<dest>]
  • Download the zip file on github directly
  • Try to find another one by yourself :/

Then place it where you want (readable location, in order to load it).

How to use

Let's say your URL is:

You can parse it with the MX\UrlParser\UrlParser class:


use MX\UrlParser\UrlParser;

$p_url = new UrlParser('');

$p_url->scheme; // === null
$p_url->host; // == ''
$p_url->subdomain; // == 'dev'
$p_url->tld; // == ''

That's it, as simple as this...!