PHPackages                             xandco/domainparser - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. xandco/domainparser

AbandonedArchivedLibrary[Validation &amp; Sanitization](/categories/validation)

xandco/domainparser
===================

Domain Parser, parses and validates a domain name.

v2.0.1(2y ago)07MITPHPPHP &gt;=8.2

Since Apr 12Pushed 1y ago1 watchersCompare

[ Source](https://github.com/xandco/domainparser)[ Packagist](https://packagist.org/packages/xandco/domainparser)[ Docs](https://github.com/xandco/domainparser)[ RSS](/packages/xandco-domainparser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (1)Versions (11)Used By (0)

Domain Parser
=============

[](#domain-parser)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dc516fab465be3439c41ba9a3af38eb0e5785a7667d605daaf5f6fe6f72e9aa7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77617264656e2f646f6d61696e2d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/warden/domain-parser)[![Total Downloads](https://camo.githubusercontent.com/f4e9f4a8d112aa97be90c5827547a51216879e6035184edad11cf99fe935db06/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77617264656e2f646f6d61696e2d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/warden/domain-parser)[![License](https://camo.githubusercontent.com/2e9242dc063aa2693e31ee8e3f37811cf0e6cab9ad6287dad9213ba7cfdb70ea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f77617264656e2f646f6d61696e2d7061727365723f7374796c653d666c61742d737175617265)](https://github.com/warden/domain-parser/blob/master/license.md)

Domain Parser simply parses a domain name you supply.

During the parsing process, the package will download a list of all [Public Suffixes](https://publicsuffix.org/list/public_suffix_list.dat) provided by [Mozilla](https://www.mozilla.org), iterate through it and save it to the systems temp folder and will update this list after a week. Next, the supplied domain will get parsed and broken up into parts and compared to the saved suffix list to determine the TLD the domain is using, then will complete a sanity check on the domain to ensure validity of it. Once this is finished, you'll receive an object containing all relevant information on the domain and its parts.

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

[](#installation)

Install this package via composer:

```
$ composer require warden/domain-parser
```

This service provider must be installed (if using anything below Laravel 5.5)

```
// config/app.php

'providers' => [
    DomainParser\DomainParserServiceProvider::class,
];
```

Publish and customize configuration file with:

```
$ php artisan vendor:publish --provider="DomainParser\DomainParserServiceProvider"
```

Usage
-----

[](#usage)

Create new `DomainParser` object:

```
use DomainParser\DomainParser;
...
$domainParser = new DomainParser( $options = [] );
```

Then call `parse()` method to parse the domain:

```
$domainParser->parse( 'www.example.com' );
```

Here is an example of the output:

```
[
    'valid_hostname' => true,
    'fqdn' => [
        'ascii' => 'www.example.com',
        'idn' => 'www.example.com'
    ],
    'sub_domains' => [
        'ascii' => [
            0 => 'www'
        ],
        'idn' => [
            0 => 'www'
        ]
    ],
    'domain' => [
        'ascii' => 'example',
        'idn' => 'example'
    ],
    'tld' => [
        'group' => [
            'ascii' => 'com',
            'idn' => 'com'
        ],
        'tld' => [
            'ascii' => 'com',
            'idn' => 'com'
        ]
    ]
]
```

### Options

[](#options)

When creating the `DomainParser` object, there is only one `array` parameter that can be passed, which is *optional*.

Options array parameters:

OptionNotesTypeDefault`output_format`options (`object`, `array`, `json`, `serialize`)`string``object``cache_path`absolute path`string``sys_get_temp_dir()``cache_life_time`in seconds`int``604800` (7 Days)`list_url`url to suffix list`string`[Public Suffix List](https://publicsuffix.org/list/effective_tld_names.dat)`list_start`start of suffix list`string``// ===BEGIN ICANN DOMAINS===``list_end`end of suffix list`string``// ===END ICANN DOMAINS===``list_remove`remove items that start with`array``['//', '!']`Instead of setting these options when creating the object, you can alternatively set these globally in the configuration file. You can publish the configuration and customize it as shown in the [Installation](#installation) section.

Changelog
---------

[](#changelog)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [X&amp;Co](https://github.com/warden)
- [Miguel Batres](https://github.com/btrsco)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT - Please see the [license file](license.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~181 days

Recently: every ~359 days

Total

9

Last Release

776d ago

Major Versions

v0.1.5 → v1.0.02020-11-29

v1.0.0 → v2.0.02024-04-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/7cd1d66aee1781a76ffde500119465ab004dcc9dfba0e9640fe80d1740f425bc?d=identicon)[xandco](/maintainers/xandco)

---

Top Contributors

[![btrsco](https://avatars.githubusercontent.com/u/1373528?v=4)](https://github.com/btrsco "btrsco (40 commits)")

---

Tags

laraveldomainparser

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/xandco-domainparser/health.svg)

```
[![Health](https://phpackages.com/badges/xandco-domainparser/health.svg)](https://phpackages.com/packages/xandco-domainparser)
```

###  Alternatives

[askedio/laravel5-profanity-filter

A Vendor Package Example

52354.1k](/packages/askedio-laravel5-profanity-filter)[laravel-validation-rules/us-state

Validate US States and Canada Provinces

16172.7k](/packages/laravel-validation-rules-us-state)[pacerit/laravel-polish-validation-rules

Simple Polish Validation rules for Laravel and Lumen framework

1449.9k](/packages/pacerit-laravel-polish-validation-rules)[laravel-validation-rules/ip

Validate if an ip address is public or private.

1629.7k](/packages/laravel-validation-rules-ip)[janvince/smallcontactform

Simple but flexible multi language contact form builder with custom fields, validation and passive antispam

307.4k](/packages/janvince-smallcontactform)[basillangevin/laravel-data-json-schemas

Transforms Spatie Data objects into JSON Schemas with built-in validation

1312.2k1](/packages/basillangevin-laravel-data-json-schemas)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
