Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Whoisdoma/DomainParser
https://github.com/Whoisdoma/DomainParser
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Whoisdoma/DomainParser
- Owner: Whoisdoma
- License: mit
- Created: 2016-06-05T17:06:29.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-12-31T13:02:06.000Z (almost 4 years ago)
- Last Synced: 2024-07-21T22:27:15.616Z (4 months ago)
- Language: PHP
- Size: 30.3 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- php-awesome - DomainParser - A domain name parser to parse and to validate a domain name (类库 / URL/Domain)
README
Whoisdoma Domain Parser
=====================A domain name parser to parse and to validate a domain name.
At first it will parse a given string to split it by the hostname and top-level domain name.
This will be done with a list from Mozilla and we also added some missing second-level domain
names. Afterwards we will convert the domain name to it punycode and unicode notation. If an
error occures by doing so, e.g. characters that are not allowed. It will kill these characters
and set a flag to false. This flag is used for the validation.Copyright (c) 2016 XAOS Interactive (http://xaosia.com) | Whoisdoma (http://whoisdoma.com)
Licensed under the MIT License (the "License").
Installation
------------
Installing using composer: `composer require whoisdoma/domainparser`Installing from source: `git clone git://github.com/Whoisdoma/DomainParser.git` or [download the latest release](https://github.com/Whoisdoma/DomainParser/zipball/master)
Move the source code to your preferred project folder.
Usage
-----
* Include Parser.php
```
require_once 'DomainParser/Parser.php';
```* or if using composer:
```
use Whoisdoma\DomainParser\Parser;
```* Create Parser() object
```
$Parser = new Whoisdoma\DomainParser\Parser();
```* Call parse() method
```
$result = $Parser->parse($string);
```* Please note, if the given string doesn't contain a domain name the default tld
.com will be added to the query. You may change this by adding a tld to the parse
method call.
```
$result = $Parser->parse($string, $yourPreferredDefaultTld);
```* You may choose 5 different return types. the types are array, object, json, serialize and
xml. By default it is object. If you want to change that call the format method before calling
the parse method or provide to the constructer. If you are not using object and an
error occurs, then exceptions will not be trapped within the response and thrown directy.
```
$Parser->setFormat('json');
$Parser = new Whoisdoma\DomainParser\Parser('json');
```3rd Party Libraries
-------------------
Thanks to developers of following used libraries:
* phlyLabs: http://phlylabs.de
* mozilla: http://www.mozilla.orgChangeLog
---------
See ChangeLog at https://github.com/Whoisdoma/DomainParser/blob/master/CHANGELOG.mdIssues
------
Please report any issues via https://github.com/Whoisdoma/DomainParser/issuesLICENSE and COPYRIGHT
---------------------
Copyright (c) 2016 XAOS Interactive (http://xaosia.com) | Whoisdoma (http://whoisdoma.com)License: https://github.com/Whoisdoma/DomainParser/blob/master/LICENSE