Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gabrieljmj/urlparser
To get information of an URL
https://github.com/gabrieljmj/urlparser
Last synced: about 2 months ago
JSON representation
To get information of an URL
- Host: GitHub
- URL: https://github.com/gabrieljmj/urlparser
- Owner: gabrieljmj
- License: other
- Created: 2014-08-31T04:44:27.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-14T02:38:23.000Z (over 10 years ago)
- Last Synced: 2023-08-21T10:27:33.688Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 160 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
GabrielJMJ\UrlParser
====================
[![Total Downloads](https://poser.pugx.org/gabrieljmj/urlparser/downloads.png)](https://packagist.org/packages/gabrieljmj/urlparser) [![Latest Unstable Version](https://poser.pugx.org/gabrieljmj/urlparser/v/unstable.png)](https://packagist.org/packages/gabrieljmj/urlparser) [![License](https://poser.pugx.org/gabrieljmj/urlparser/license.png)](https://packagist.org/packages/gabrieljmj/urlparser) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/GabrielJMJ/UrlParser/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/GabrielJMJ/UrlParser/?branch=master)To parse an URL to get informations.
##Download and autoload
###Via Composer
####Download
```json
{
"require": {
"gabrieljmj/urlparser": "dev-master"
}
}
```
####Autoload
```json
{
"autoload": {
"psr-4": {
"Gabrieljmj\\UrlParser\\": "vendor/gabrieljmj/urlparser/src/Gabrieljmj/UrlParser/",
"Test\\": "tests/"
}
}
}
```
##Examples
```php
use Gabrieljmj\UrlParser\UrlParser;$urlParser = new UrlParser();
$urlData = $urlParser->url('https://github.com/search?q=some+search');echo 'Protocol: ' . $urlData->getProtocol() . "\n" .
'Host: ' . $urlData->getHost() . "\n" .
'Tld: ' . $urlData->getTld() . "\n" .
'Path: ' . print_r($urlData->getPath(), true) . "\n" .
'Query: ' . print_r($urlData->getQuery, true);
```
Returns:
```php
Protocol: https
Host: github.com
Tld: .com
Path: Array([0] => search)
Query: Array([q] => some+search)
```
URL has subdomain: Pass as second param on ```Gabrieljmj\UrlParser\UrlParser::url(string $url [, boolean $hasSubsmain = false])``` the value ```true```.