PHPackages                             ljpc/pure-php-doh-client - 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. ljpc/pure-php-doh-client

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

ljpc/pure-php-doh-client
========================

Easily query DNS records via HTTPS

1.3.0(2y ago)513.3k↓42.2%1[1 PRs](https://github.com/LJPc-solutions/Pure-PHP-DoH-Client/pulls)GPL-3.0-or-laterPHPPHP ^8.0

Since Feb 4Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/LJPc-solutions/Pure-PHP-DoH-Client)[ Packagist](https://packagist.org/packages/ljpc/pure-php-doh-client)[ Fund](https://www.buymeacoffee.com/Lars-)[ RSS](/packages/ljpc-pure-php-doh-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (5)Used By (0)

Pure PHP DoH Client
===================

[](#pure-php-doh-client)

This library finally makes it easy to query DNS records in PHP without any third party extensions.

[![Buy Me A Coffee](https://camo.githubusercontent.com/8bd3ccfc24697740a514437b301e19057ace3c1be9903d755eef2891228bffc6/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d6f72616e67652e706e67)](https://www.buymeacoffee.com/Lars-)

Features
--------

[](#features)

- Automatically query multiple DoH servers (round-robin)
- Prefilled with CloudFlare, Google, Quad9 and AdGuard DoH servers
- Easy to expand servers
- Easy to expand resource records
- No `dig` required, everything is pure PHP
- Everything is JSON Serializable

Resource records
----------------

[](#resource-records)

The following resource records are available:

- A
- AAAA
- CAA
- CNAME
- DNAME
- DNSKEY
- DS
- KEY
- LOC
- MX
- NS
- NSEC
- PTR
- RRSIG
- SOA
- SPF
- SRV
- TXT
- URI
- TLSA

Installation &amp; loading
--------------------------

[](#installation--loading)

LJPc Pure PHP DoH Client is available on [Packagist](https://packagist.org/packages/ljpc/pure-php-doh-client) (using semantic versioning), and installation via [Composer](https://getcomposer.org) is the recommended way to install this library.

Just run:

```
composer require ljpc/pure-php-doh-client
```

Or add this line to your `composer.json` file:

```
"ljpc/pure-php-doh-client": "^1.0"
```

Structure
---------

[](#structure)

- `\LJPc\DoH\DNS::query` always returns a `\LJPc\DoH\DNSQueryResult` which contains the following fields:
    - used server (`->getServer()`) \[string\]
    - answers (`->getAnswers()`) \[array of \\LJPc\\DoH\\DNSRecord\]
    - authorityRecords (`->getAuthorityRecords()`) \[array of \\LJPc\\DoH\\DNSRecord\]
    - additionalRecords (`->getAdditionalRecords()`) \[array of \\LJPc\\DoH\\DNSRecord\]
- `\LJPc\DoH\DNSRecord` always has the following fields:
    - domainname \[string\]
    - ttl \[int\] (according to the queried server)
    - type \[string\] (e.g. A or MX)
    - extras \[array\] (e.g. the priority in an MX record)
    - value \[string\]

Example
-------

[](#example)

Get the A records for cloudflare.com:

```
