PHPackages                             jdwx/dns-query - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. jdwx/dns-query

ActiveLibrary[HTTP &amp; Networking](/categories/http)

jdwx/dns-query
==============

Native PHP DNS Resolver and Updater Library (PHP 8.1+)

v2.0.9(2mo ago)34.5k↓41.7%2BSD-2-ClausePHPPHP &gt;=8.1

Since May 28Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/jdwx/dns-query)[ Packagist](https://packagist.org/packages/jdwx/dns-query)[ Docs](https://github.com/jdwx/dns-query/)[ RSS](/packages/jdwx-dns-query/feed)WikiDiscussions version-2.0.x Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (27)Used By (0)

DNSQuery - Native PHP DNS Resolver and Updater
==============================================

[](#dnsquery---native-php-dns-resolver-and-updater)

### The main features for this package include:

[](#the-main-features-for-this-package-include)

- Uses modern PHP namespaces, classes and exceptions
- Support for IPv4 and IPv6, TCP and UDP sockets.
- Includes a separate "Updater" class for handling dynamic update
- Support zone signing using TSIG and SIG(0) for updates and zone transfers
- Supports using PSR-6/PSR-16 caching implementations to improve performance
- Includes many RRs, including DNSSEC RRs.
- Full PHP 8.1 compatibility.

Installing DNSQuery
-------------------

[](#installing-dnsquery)

You can require it directly via Composer:

```
composer require jdwx/dns-query

```

Or download the source from Github:

Requirements
------------

[](#requirements)

- PHP 8.1+
- The PHP INI setting `mbstring.func_overload` equals 0, 1, 4, or 5.

Using DNSQuery
--------------

[](#using-dnsquery)

DNSQuery provides multiple interfaces depending on requirements.

The simplest interface is designed to mimic PHP's built-in dns\_get\_record() function with additional flexibility to query other name servers.

```
$out = Resolver::dns_get_record( 'google.com', DNS_MX );
var_dump( $out );
```

```
array(1) {
  [0] =>
  array(6) {
    'host' =>
    string(10) "google.com"
    'class' =>
    string(2) "IN"
    'ttl' =>
    int(300)
    'type' =>
    string(2) "MX"
    'pri' =>
    int(10)
    'target' =>
    string(15) "smtp.google.com"
  }
}

```

But it allows specifying additional options, like what name server to use for the lookup:

```
$out = Resolver::dns_get_record( 'google.com', DNS_MX, '1.1.1.1' );
var_dump( $out );
```

(Produces the same output as above.)

You can also specify a list of name servers or a custom resolv.conf file to use for the lookup. (See the examples.)

For repeated queries, the resolver should be instantiated. It provides a compatability interface in that form as well:

```
$rsv = new Resolver();
$out = $rsv->compatQuery( 'google.com', DNS_MX );
var_dump( $out );
```

(Produces the same output as above.)

The native query interface returns full detail about the response from the name server contacted:

```
$rsv = new Resolver();
$out = $rsv->query( 'google.com', 'MX' );
var_dump( $out );
```

```
class JDWX\DNSQuery\Packet\ResponsePacket#13 (12) {
  public string $rdata =>
  string(49) "(binary data)"
  public int $rdLength =>
  int(49)
  public int $offset =>
  int(49)
  public JDWX\DNSQuery\Packet\Header $header =>
  class JDWX\DNSQuery\Packet\Header#14 (15) {
    public int $id =>
    int(37144)
    public int $qr =>
    int(1)
    public int $opcode =>
    int(0)
    public int $aa =>
    int(0)
    public int $tc =>
    int(0)
    public int $rd =>
    int(1)
    public int $ra =>
    int(1)
    public int $zero =>
    int(0)
    public int $ad =>
    int(0)
    public int $cd =>
    int(0)
    public int $rCode =>
    int(0)
    public int $qdCount =>
    int(1)
    public int $anCount =>
    int(1)
    public int $nsCount =>
    int(0)
    public int $arCount =>
    int(0)
  }
  public array $question =>
  array(1) {
    [0] =>
    class JDWX\DNSQuery\Question#15 (3) {
      public string $qName =>
      string(10) "google.com"
      public string $qType =>
      string(2) "MX"
      public string $qClass =>
      string(2) "IN"
    }
  }
  public array $answer =>
  array(1) {
    [0] =>
    class JDWX\DNSQuery\RR\MX#16 (8) {
      public string $name =>
      string(10) "google.com"
      public string $type =>
      string(2) "MX"
      public string $class =>
      string(2) "IN"
      public int $ttl =>
      int(226)
      public int $rdLength =>
      int(9)
      public string $rdata =>
      string(9) "(binary data)"
      public int $preference =>
      int(10)
      public string $exchange =>
      string(15) "smtp.google.com"
    }
  }
  public array $authority =>
  array(0) {
  }
  public array $additional =>
  array(0) {
  }
  private array $compressed =>
  array(0) {
  }
  public string $answerFrom =>
  string(7) "1.1.1.1"
  public int $answerSocketType =>
  int(2)
  public float $responseTime =>
  double(0.0037810802459717)
}

```

Documentation
-------------

[](#documentation)

Documentation is being developed [here](https://github.com/jdwx/dns-query/wiki).

Stability
---------

[](#stability)

Development of test coverage for this package is incomplete and is currently limited to the Resolver functionality. The Updater and Notifier are not yet tested, and not all RRs have test coverage.

History
-------

[](#history)

This package was forked from Net\_DNS2, which was maintained by Mike Pultz until 2020. Key differences are:

- PEAR support has been removed.
- Certain things that were previously optional (e.g., the [filter extension](https://www.php.net/manual/en/book.filter.php)) are now required.
- Replaced the hard-to-validate array-style options configuration with fluent setters.
- Changed cache implementation
- Use PSR-4 namespaces and compatible autoloading.
- Passes my organization's internal code quality standards.
- Substantial refactoring of networking code for future flexibility (e.g., DNS over HTTPS).
- Additional unit tests.

I apologize that backwards compatibility is **not** a priority; my company required adherence to certain coding standards in order to support this work. This is therefore likely only suited for new development.

The original package represents an enormous amount of work done over many years. As such Mike Pultz deserves full credit for most of this package; most of what I am doing is window dressing and adapting it to meet my specific needs. But since this is a public repository, I wanted to make clear that I do not claim credit for Mike's original work.

See the [Net\_DNS2 Website](https://netdns2.com/) for more details about Net\_DNS2.

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance82

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 73.8% 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 ~221 days

Recently: every ~18 days

Total

22

Last Release

89d ago

Major Versions

v1.5.2 → v2.0.0-beta.12022-07-17

PHP version history (4 changes)1.2.5PHP &gt;=5.1.2

v1.5.0PHP &gt;=5.4

v2.0.0-beta.1PHP &gt;=8.1

v2.0.6PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/f71b4b976170f89eac19be48c7381a27c49ed8c9cb5e8e6ff05a2ad7583efa13?d=identicon)[jdwx](/maintainers/jdwx)

---

Top Contributors

[![mikepultz](https://avatars.githubusercontent.com/u/4993169?v=4)](https://github.com/mikepultz "mikepultz (48 commits)")[![jdwx](https://avatars.githubusercontent.com/u/2722779?v=4)](https://github.com/jdwx "jdwx (6 commits)")[![hunbalazs](https://avatars.githubusercontent.com/u/1272471?v=4)](https://github.com/hunbalazs "hunbalazs (2 commits)")[![bishopb](https://avatars.githubusercontent.com/u/6844145?v=4)](https://github.com/bishopb "bishopb (2 commits)")[![pstast](https://avatars.githubusercontent.com/u/5357442?v=4)](https://github.com/pstast "pstast (1 commits)")[![rhuijts](https://avatars.githubusercontent.com/u/28596457?v=4)](https://github.com/rhuijts "rhuijts (1 commits)")[![adpeyre](https://avatars.githubusercontent.com/u/12408697?v=4)](https://github.com/adpeyre "adpeyre (1 commits)")[![romaven](https://avatars.githubusercontent.com/u/13623163?v=4)](https://github.com/romaven "romaven (1 commits)")[![BugMaster510945](https://avatars.githubusercontent.com/u/169523856?v=4)](https://github.com/BugMaster510945 "BugMaster510945 (1 commits)")[![gbxyz](https://avatars.githubusercontent.com/u/665401?v=4)](https://github.com/gbxyz "gbxyz (1 commits)")[![InboxViktorV](https://avatars.githubusercontent.com/u/71443952?v=4)](https://github.com/InboxViktorV "InboxViktorV (1 commits)")

---

Tags

dnsphp8resolver-librarydnsnetwork

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jdwx-dns-query/health.svg)

```
[![Health](https://phpackages.com/badges/jdwx-dns-query/health.svg)](https://phpackages.com/packages/jdwx-dns-query)
```

###  Alternatives

[mikepultz/netdns2

PHP DNS Resolver and Updater Library

1292.1k5](/packages/mikepultz-netdns2)

PHPackages © 2026

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