PHPackages                             stormcode/php-domain-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. stormcode/php-domain-parser

ActiveLibrary

stormcode/php-domain-parser
===========================

Public Suffix List based URL parsing implemented in PHP.

v1.1(3y ago)120.1k↓26.2%1MITPHPPHP &gt;=8.0

Since Jan 15Pushed 3y ago1 watchersCompare

[ Source](https://github.com/xTermy/php-domain-parser)[ Packagist](https://packagist.org/packages/stormcode/php-domain-parser)[ RSS](/packages/stormcode-php-domain-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (1)

PHP Domain Parser
=================

[](#php-domain-parser)

**PHP Domain Parser** is a [Public Suffix List](http://publicsuffix.org/) based domain parser implemented in PHP.

Motivation
----------

[](#motivation)

While there are plenty of excellent URL parsers and builders available, there are very few projects that can accurately parse a url into its component subdomain, registerable domain, and public suffix parts.

Consider the domain [www.pref.okinawa.jp](http://www.pref.okinawa.jp). In this domain, the *public suffix* portion is **okinawa.jp**, the *registerable domain* is **pref.okinawa.jp**, and the *subdomain* is **www**. You can't regex that.

Other similar libraries focus primarily on URL building, parsing, and manipulation and additionally include public suffix domain parsing. PHP Domain Parser was built around accurate Public Suffix List based parsing from the very beginning, adding a URL object simply for the sake of completeness.

Installation
------------

[](#installation)

The only (currently) supported method of installation is via [Composer](http://getcomposer.org).

Create a `composer.json` file in the root of your project:

```
{
    "require": {
        "stormcode/php-domain-parser": "~1.0"
    }
}
```

And then run: `composer install`

Add the autoloader to your project:

```
