PHPackages                             murilo-perosa/domain-tools - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. murilo-perosa/domain-tools

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

murilo-perosa/domain-tools
==========================

Handle domains and DNS tools.

v1.0.8(2y ago)122.7k3MITPHPPHP &gt;=7.3

Since Mar 31Pushed 2y ago2 watchersCompare

[ Source](https://github.com/muriloperosa/domain-tools)[ Packagist](https://packagist.org/packages/murilo-perosa/domain-tools)[ RSS](/packages/murilo-perosa-domain-tools/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (17)Used By (0)

Domain Tools
============

[](#domain-tools)

[![Latest Stable Version](https://camo.githubusercontent.com/512545ae67ee452ec5535eedd3ec25f3b26fe65af95deac45ec83b80f593e970/68747470733a2f2f706f7365722e707567782e6f72672f6d7572696c6f2d7065726f73612f646f6d61696e2d746f6f6c732f76)](//packagist.org/packages/murilo-perosa/domain-tools) [![Total Downloads](https://camo.githubusercontent.com/72067390f4b1a281aadf3c6a63d8b9dc0cbb3f9980a506c95fd6801779a64655/68747470733a2f2f706f7365722e707567782e6f72672f6d7572696c6f2d7065726f73612f646f6d61696e2d746f6f6c732f646f776e6c6f616473)](//packagist.org/packages/murilo-perosa/domain-tools) [![License](https://camo.githubusercontent.com/fa5f0f08b8dc7478aed3dd596037b0ef5405a1e616126373fae6a52f1c162654/68747470733a2f2f706f7365722e707567782e6f72672f6d7572696c6f2d7065726f73612f646f6d61696e2d746f6f6c732f6c6963656e7365)](//packagist.org/packages/murilo-perosa/domain-tools)

PHP - Simple library to deal with basic DNS situations.

- Name Conversion;
- Name Sanitization;
- Name Validation;
- Check name SSL certificate;
- Check name servers;
- Get name parts (sufix, domain, subdomain);
- Get public sufix list;
- Get and/or search for DNS records: 'A', 'AAAA', 'CNAME', 'NS', 'SOA', 'MX', 'SRV', 'TXT', 'CAA', 'NAPTR', 'PTR', 'HINFO', 'A6'.

Install
-------

[](#install)

```
composer require murilo-perosa/domain-tools
```

Update
------

[](#update)

```
composer update murilo-perosa/domain-tools
```

Unit Tests
----------

[](#unit-tests)

To run unit tests using PHPUnit:

```
./vendor/bin/phpunit src/tests
```

Lint
----

[](#lint)

To run PHPLint:

```
./vendor/bin/phplint ./
```

Name.php
--------

[](#namephp)

Class used to handle Domains and Subdomains names.

### Variables

[](#variables)

```
/**
 * Current name
 * @var string
 */
public $name;

/**
 * Name Subdomain
 * @var string
 */
public $subdomain;

/**
 * Name Domain
 * @var string
 */
public $domain;

/**
 * Name sufix
 * @var string
 */
public $sufix;

/**
 * Name is a subdomain
 * @var boolean
 */
public $is_subdomain;

/**
 * List of Subdomains
 * @var array
 */
public $subdomains;

/**
 * Parts of name
 * @var array
 */
public $parts;

/**
 * Segments of name
 * @var array
 */
public $segments;

/**
 * Name is valid
 * @var bool
 */
public $is_valid;

/**
 * Domain records
 * @var Record
 */
public $records;
```

### Instance the class

[](#instance-the-class)

```
use MuriloPerosa\DomainTools\Name;

// instance the class
$name = new Name('google.com');
```

### Change state functions

[](#change-state-functions)

```
// convert name to UTF-8
$name->idnToUtf8();

// convert name to ASCII
$name->idnToAscii();

// sanitize the name
$name->sanitize(false);

// sanitize the name and remove "www."
$name->sanitize(true);

// you can use them like this
$name->idnToUtf8()
    ->sanitize();
```

### General functions

[](#general-functions)

```
// get current name servers
$name_servers = $name->getNameServers();

// check if name has ssl certificate
$has_ssl = $name->hasSsl();
```

Sufix.php
---------

[](#sufixphp)

Class used to handle names sufix.

### General Functions

[](#general-functions-1)

```
use MuriloPerosa\DomainTools\Sufix;
use MuriloPerosa\DomainTools\Name;

// get the sufix list
$list = Sufix::getSufixList();

// get name sufix
$name = new Name('google.com');
$sufix = Sufix::getDnsSufix($name);
```

NameHelper.php
--------------

[](#namehelperphp)

Helper that contains static funtions for treatment situations.
You must use that class when you need to apply quick operations to the name.

### General Functions

[](#general-functions-2)

```
use MuriloPerosa\DomainTools\Helpers\NameHelper;

// Sanitize name
$name = NameHelper::sanitize('https://google.com', true); // 'https://google.com' => 'google.com'

// Split name in parts
$name = NameHelper::splitInParts('google.com'); // 'google.com' => ['google', 'com']

// Return name in segment
$name = NameHelper::splitInSegments('google.com'); // 'google.com' => ['com', 'google.com']

// Validate name
$is_valid = NameHelper::validate('google.com'); // true

// Convert domain name from IDN to UTF-8
$name = NameHelper::idnToUtf8('xn--tst-qla.de'); // 'täst.de'

// Convert domain name from IDN to ASCII
$name = NameHelper::idnToASCII('täst.de'); // 'xn--tst-qla.de'

// Check if name has SSL Certificate
$has_ssl = NameHelper::hasSsl('google.com'); // true
```

Record.php
----------

[](#recordphp)

Class used to handle DNS Records.

### Variables

[](#variables-1)

```
/**
 * Domain
 * @param string
 */
public $domain;

/**
 * Allowed records to get
 * @param array
 */
private $allowed_records;
```

### Instance the class

[](#instance-the-class-1)

```
use MuriloPerosa\DomainTools\Record;

// instance the class
$dns = new Record('google.com');

// OR

use MuriloPerosa\DomainTools\Name;

$name = new Name('google.com');
$dns = $name->records;
```

### General functions

[](#general-functions-3)

```
// Return array with all records
$records = $dns->getAll();

// Return array with all NS records
$records = $dns->getNS();

// Return array with all A records
$records = $dns->getA();

// Return array with all AAAA records
$records = $dns->getAAAA();

// Return array with all CNAME records
$records = $dns->getCNAME();

// Return array with all SOA records
$records = $dns->getSOA();

// Return array with all MX records
$records = $dns->getMX();

// Return array with all SRV records
$records = $dns->getSRV();

// Return array with all TXT records
$records = $dns->getTXT();

// Return array with all CAA records
$records = $dns->getCAA();  // Not works on Windows (OS)

// Return array with all NAPTR records
$records = $dns->getNAPTR();

// Return array with all PTR records
$records = $dns->getPTR();

// Return array with all HINFO records
$records = $dns->getHINFO();

// Return array with all A6 records
$records = $dns->getA6();

// Dinamic record search - returns a result array
$records = $dns->search($type, $host);

// to get records of all types or hosts you can use '*'
$records = $dns->search('*', '*');

// you can use a string to specify wich type or host you want to search
$records = $dns->search('A', 'php.net');

// you can use arrays to specify wich types or hosts you want to search
$records = $dns->search(['A', 'MX'], ['php.net', 'blabla']);

// You can use a mix of approaches
// $records = $dns->search('*', '*');
// $records = $dns->search('*', 'php.net');
// $records = $dns->search('A', '*');
// $records = $dns->search(['A', 'MX'], ['php.net', 'blabla']);
// $records = $dns->search('*', ['php.net', 'blabla']);
// $records = $dns->search('A', ['php.net', 'blabla']);
// $records = $dns->search(['A', 'MX'], '*');
// $records = $dns->search(['A', 'MX'], 'php.net');
// $records = $dns->search(['A', 'MX'], ['php.net', 'blabla']);
```

Author
------

[](#author)

Murilo Perosa &lt;&gt;

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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 ~74 days

Recently: every ~220 days

Total

13

Last Release

979d ago

Major Versions

v0.1.0 → v1.0.02021-04-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/ffa16840bdbb95f677ba5ebf374e627a432129f3cc627e6f19efbbb2c0d65b73?d=identicon)[Murilo Perosa](/maintainers/Murilo%20Perosa)

---

Top Contributors

[![muriloperosa](https://avatars.githubusercontent.com/u/45050585?v=4)](https://github.com/muriloperosa "muriloperosa (61 commits)")

---

Tags

composerdnsdns-situationsdomainhelperpackagephpsslsubdomainsufixtraitunit-testing

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/murilo-perosa-domain-tools/health.svg)

```
[![Health](https://phpackages.com/badges/murilo-perosa-domain-tools/health.svg)](https://phpackages.com/packages/murilo-perosa-domain-tools)
```

PHPackages © 2026

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