cboxdk/laravel-dns
Composer 安装命令:
composer require cboxdk/laravel-dns
包简介
Laravel integration for cboxdk/dns — authoritative DNS lookups, domain-ownership verification, DNSSEC validation, and intoDNS/MxToolbox-style diagnostics via a facade, Artisan commands, and validation rules.
关键字:
README 文档
README
The DNS toolkit for Laravel: authoritative lookups, domain-ownership verification, DNSSEC validation, and intoDNS/MxToolbox-style diagnostics — exposed through a facade, Artisan commands, and validation rules.
This package is the Laravel integration for the framework-agnostic
cboxdk/dns engine. The DNS protocol handling,
verification, propagation, SPF/DMARC parsing, and DNSSEC chain validation all live
in that core library; this package wires it into the container, config, the
console, and the validator so it is one composer require away in a Laravel app.
Installation
composer require cboxdk/laravel-dns
The service provider is auto-discovered. Publish the config if you want to tune the resolver:
php artisan vendor:publish --tag="dns-config"
It works with zero configuration out of the box (a raw UDP/TCP socket resolver
against 1.1.1.1).
Configuration
config/dns.php:
| Key | Env | Default | Purpose |
|---|---|---|---|
resolver |
DNS_RESOLVER |
socket |
Transport: socket (raw UDP/TCP) or doh (DNS-over-HTTPS JSON). |
nameserver |
DNS_NAMESERVER |
1.1.1.1 |
Recursive resolver for the socket transport. |
timeout |
DNS_TIMEOUT |
3.0 |
Per-query timeout, seconds. |
doh_endpoint |
DNS_DOH_ENDPOINT |
https://dns.google/resolve |
JSON DoH endpoint when resolver=doh. |
challenge_prefix |
DNS_CHALLENGE_PREFIX |
_cbox-challenge |
Label for ownership-verification TXT records. |
allow_non_public_nameservers |
DNS_ALLOW_NON_PUBLIC_NAMESERVERS |
false |
Lifts the SSRF filter on authoritative reads. Local testing only. |
The
sockettransport can target a zone's own authoritative nameservers, which domain-ownership verification and propagation checks require. Thedohtransport only queries a provider's recursive resolver, so it cannot answer authoritative or propagation queries.
Facade
use Cbox\LaravelDns\Facades\Dns; use Cbox\Dns\Enums\RecordType; $response = Dns::lookup('example.com', RecordType::MX); $response->values(); // ['mail.example.com'] Dns::verifyDomain('example.com', $token); // bool — read authoritatively Dns::challengeHost('example.com'); // '_cbox-challenge.example.com' $report = Dns::diagnose('example.com'); // Cbox\Dns\Diagnostics\Report $report->hasErrors(); Dns::dnssec()->validate('example.com'); // Cbox\Dns\Dnssec\ValidationResult
You can also inject the core types directly — the container binds both
Cbox\Dns\Dns and the Cbox\Dns\Contracts\Resolver contract:
public function __construct(private \Cbox\Dns\Dns $dns) {}
Artisan commands
php artisan dns:lookup example.com MX # table of records php artisan dns:verify example.com <token> # ownership challenge + result php artisan dns:diagnose example.com # grouped findings, non-zero exit on errors php artisan dns:propagation www.example.com A example.com [--all] php artisan dns:dnssec example.com # secure / insecure / bogus + reason
Validation rules
use Cbox\LaravelDns\Rules\DnsRecordExists; use Cbox\LaravelDns\Rules\DomainVerified; use Cbox\Dns\Enums\RecordType; $request->validate([ 'mail_domain' => ['required', new DnsRecordExists(RecordType::MX)], 'domain' => ['required', new DomainVerified($team->dns_token)], ]);
DnsRecordExists fails when the value resolves no record of the given type;
DomainVerified fails unless the value publishes the challenge token in its
authoritative TXT record.
Testing
Compose InteractsWithDns into your host application's TestCase to stub records
and assert with zero network I/O:
use Cbox\LaravelDns\Testing\InteractsWithDns; use Cbox\Dns\Enums\RecordType; $this->fakeDns()->stub('example.com', RecordType::MX, ['mail.example.com']); Dns::lookup('example.com', RecordType::MX)->values(); // ['mail.example.com']
fakeDns() swaps the container's resolver and Dns bindings for an in-memory
fake, so the facade, commands, and validation rules all resolve stubbed records.
Requirements
- PHP 8.4+
- Laravel 12.x or 13.x
The DNS engine
All DNS behaviour is provided by cboxdk/dns —
including the spoofing-resistant resolver, the SSRF-guarded authoritative reader,
SPF/DMARC/CAA parsing, and DNSSEC chain validation against the IANA root trust
anchors. This package claims only the Laravel integration.
Documentation
Full documentation lives in docs/.
Credits
License
The MIT License (MIT). See LICENSE.md.
cboxdk/laravel-dns 适用场景与选型建议
cboxdk/laravel-dns 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 07 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「dns」 「laravel」 「spf」 「propagation」 「dmarc」 「DNSSEC」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cboxdk/laravel-dns 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cboxdk/laravel-dns 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cboxdk/laravel-dns 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
WordPress mu-plugin to set sender/return path for mail if not set..
This authres_status plugin checks the Authentication-Results headers of your emails and displays the verification status. The verification status is displayed when you read an email, but you can also add a column to your message list.
🔏 Stand-alone DKIM class to sign your emails with a 2048 bit private key hashed with SHA-256 algorithm.
An advanced PHP library for email validation with DNS checks and typo suggestions.
Checks for configured mail athentication methods like SPF, DKIM and DMARC
Mail configuration check tool
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-15