Package Data | |
---|---|
Maintainer Username: | Max13 |
Maintainer Contact: | adnan@rihan.fr (Adnan RIHAN) |
Package Create Date: | 2013-11-14 |
Package Last Update: | 2014-01-14 |
Language: | PHP |
License: | CC-BY-NC-SA-3.0 |
Last Refreshed: | 2024-12-11 15:24:40 |
Package Statistics | |
---|---|
Total Downloads: | 619 |
Monthly Downloads: | 7 |
Daily Downloads: | 0 |
Total Stars: | 3 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 1 |
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 https://dev.api.example.co.uk/1/2/3?key=val#anchor
):
scheme
: https
host
: dev.api.example.co.uk
path
: /1/2/3
query
: key=val
fragment
: anchor
subdomain
: dev
domain
: api.example
tld
: co.uk
5.3
There are several ways to download MxUrlParser-PHP:
"max13/url-parser": "dev-master"
)git clone <repo> [<dest>]
Then place it where you want (readable location, in order to load it).
Let's say your URL is: dev.api.example.co.uk/1/2/3?key=val#anchor
You can parse it with the MX\UrlParser\UrlParser
class:
<?php
use MX\UrlParser\UrlParser;
$p_url = new UrlParser('dev.api.example.co.uk/1/2/3?key=val#anchor');
/*
$p_url->scheme; // === null
$p_url->host; // == 'dev.api.example.co.uk'
$p_url->subdomain; // == 'dev'
$p_url->tld; // == 'co.uk'
*/
?>
That's it, as simple as this...!