PHPackages                             jinomial/laravel-dns - 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. jinomial/laravel-dns

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

jinomial/laravel-dns
====================

A DNS service for Laravel

v4.0.1(4mo ago)433MITPHPPHP 8.2 - 8.4CI passing

Since Oct 7Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/jinomial/laravel-dns)[ Packagist](https://packagist.org/packages/jinomial/laravel-dns)[ Docs](https://github.com/jinomial/laravel-dns)[ RSS](/packages/jinomial-laravel-dns/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)Dependencies (6)Versions (8)Used By (0)

Laravel DNS
===========

[](#laravel-dns)

A powerful DNS service and facade for Laravel. V4 brings a robust model-based architecture, semantic query methods, and built-in caching.

DriverDescriptiondohDNS over HTTPS (DoH)systemPHP's `dns_get_record()`googleSpecialized Google DNS (DoH)cloudflareSpecialized Cloudflare (DoH)digSystem `dig` command wrapperarrayMock/Static records driverudpCustom UDP DNS (RFC 1035)Installation
------------

[](#installation)

Install the package via composer:

```
composer require jinomial/laravel-dns
```

Publish the config file:

```
php artisan vendor:publish --provider="Jinomial\LaravelDns\DnsServiceProvider" --tag="laravel-dns-config"
```

The default configuration uses Cloudflare DoH:

```
'doh' => [
    'driver' => 'doh',
    'endpoint' => env('DOH_ENDPOINT', 'https://cloudflare-dns.com/dns-query'),
    'timeout' => 5.0,
],
```

Usage
-----

[](#usage)

V4 returns `DnsRecordCollection` containing `DnsRecord` objects, providing a consistent API across drivers.

### Basic Query

[](#basic-query)

```
use Jinomial\LaravelDns\Facades\Dns;

$records = Dns::query('google.com', 'A');

foreach ($records as $record) {
    echo $record->host; // "google.com"
    echo $record->data; // "142.250.xxx.xxx"
    echo $record->ttl;  // 300
}
```

### Semantic Methods

[](#semantic-methods)

V4 includes convenient semantic methods for common record types:

```
$a    = Dns::getA('google.com');
$aaaa = Dns::getAAAA('google.com');
$mx   = Dns::getMX('google.com');
$txt  = Dns::getTXT('google.com');
$ns   = Dns::getNS('google.com');
$ptr  = Dns::getPTR('8.8.8.8');
```

### Caching

[](#caching)

Easily cache DNS results using the `remember` method:

```
// Cache the result for 60 seconds
$records = Dns::remember(60)->getA('google.com');
```

### Use a Specific Driver

[](#use-a-specific-driver)

```
$records = Dns::socket('system')->query('google.com', 'A');
```

Batch Queries
-------------

[](#batch-queries)

Multiple lookups can be performed at once. In DoH, these can be performed asynchronously.

```
$records = Dns::query([
    ['name' => 'google.com', 'type' => 'A'],
    ['name' => 'github.com', 'type' => 'AAAA'],
]);
```

### Asynchronous Queries (DoH only)

[](#asynchronous-queries-doh-only)

```
// Returns a DnsRecordCollection after resolving all promises
$records = Dns::socket('doh')->query($queries, null, ['async' => true]);
```

DnsRecord Model
---------------

[](#dnsrecord-model)

The `DnsRecord` model standardizes DNS data across all drivers:

```
$record->host;   // The host name
$record->type;   // The record type (e.g., "A", "MX")
$record->ttl;    // Time to live
$record->data;   // The record value (IP, Target, etc.)
$record->class;  // Usually "IN"
$record->extras; // Array of driver-specific raw data
```

The `DnsRecordCollection` extends `Illuminate\Support\Collection`, giving you access to all Laravel collection methods like `filter`, `map`, and `pluck`.

Migration from V3 to V4
-----------------------

[](#migration-from-v3-to-v4)

V4 is a major refactor focused on type safety and developer experience.

### Return Type Changes

[](#return-type-changes)

- **V3**: `query()` returned raw arrays specific to each driver.
- **V4**: `query()` returns a `Jinomial\LaravelDns\DnsRecordCollection`.

**Update Needed**: If you were accessing array keys directly, update to object properties or use `toArray()`.

```
// V3
$ip = $response['Answer'][0]['data'];

// V4
$ip = $records->first()->data;
```

### Driver Interface

[](#driver-interface)

If you implemented custom drivers, you must update your `query()` method signature to return `DnsRecordCollection`.

### Manager Changes

[](#manager-changes)

`DnsManager` now extends `Illuminate\Support\Manager`. `forgetDrivers()` is still supported but `forgetSockets()` is preferred for semantic consistency.

Custom Drivers
--------------

[](#custom-drivers)

Create a class that implements `Jinomial\LaravelDns\Contracts\Dns\Socket`.

Register your driver in a Service Provider:

```
public function boot(): void
{
    $this->app->make(\Jinomial\LaravelDns\DnsManager::class)->extend('custom', function ($app, $name, $config) {
        return new MyCustomDriver($name, $config);
    });
}
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance76

Regular maintenance activity

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity73

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

Recently: every ~224 days

Total

7

Last Release

131d ago

Major Versions

v1.0.0-beta.2 → v2.0.12023-08-31

v2.0.1 → v3.0.02025-01-01

v3.1.0 → v4.0.02026-02-13

PHP version history (3 changes)v1.0.0-beta.1PHP ^8.0

v2.0.1PHP ^8.1

v3.0.0PHP 8.2 - 8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/26f680a2a0545691ca0b1e8268798ef37d6ab3f0942289914d7a58f49efddf99?d=identicon)[jinomial](/maintainers/jinomial)

---

Top Contributors

[![jinomial](https://avatars.githubusercontent.com/u/91918643?v=4)](https://github.com/jinomial "jinomial (9 commits)")

---

Tags

laraveldnsdohlaravel-dnsjinomial

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/jinomial-laravel-dns/health.svg)

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

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M829](/packages/laravel-socialite)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M153](/packages/spatie-laravel-health)[omniphx/forrest

A Laravel library for Salesforce

2724.6M9](/packages/omniphx-forrest)[sunchayn/nimbus

A Laravel package providing an in-browser API client with automatic schema generation, live validation, and built-in authentication with a touch of Laravel-tailored magic for effortless API testing.

32837.0k](/packages/sunchayn-nimbus)[muhammadhuzaifa/telescope-guzzle-watcher

Telescope Guzzle Watcher provide a custom watcher for intercepting http requests made via guzzlehttp/guzzle php library. The package uses the on\_stats request option for extracting the request/response data. The watcher intercept and log the request into the Laravel Telescope HTTP Client Watcher.

98262.9k2](/packages/muhammadhuzaifa-telescope-guzzle-watcher)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)

PHPackages © 2026

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