cr0w/phind 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cr0w/phind

Composer 安装命令:

composer require cr0w/phind

包简介

Local-first service resolution

关键字:

README 文档

README

Local-first DNS.

Records, wildcards, runtime management, upstream fallback.

Install

Requires the Swoole PHP extension:

pecl install swoole

Install globally:

composer global require cr0w/phind

Make sure Composer's global bin directory is on your PATH:

export PATH="$PATH:$(composer global config bin-dir --absolute)"

Or install locally in a project:

composer require cr0w/phind

Usage

bin/phind
# [DNS:UDP] Listening on 0.0.0.0:8053
# [DNS:TCP] Listening on 0.0.0.0:8053

bin/phind-http
# [HTTP] Listening on http://127.0.0.1:8080

Records

Records live at ~/.phind/records.json by default:

{
  "*.phind": [
    { "type": "A", "value": "127.0.0.1", "ttl": 300 }
  ]
}

Override the path:

export PHIND_STORAGE_PATH=/your/path

Wildcards, multiple domains, and cross-host targets all work, all part of the same naming layer:

{
  "*.dev":    [{ "type": "A", "value": "127.0.0.1" }],
  "api.local":[{ "type": "A", "value": "127.0.0.1" }],
  "db.test":  [{ "type": "A", "value": "192.168.1.50" }]
}

phind requires a restart to pick up changes to the records file directly. To add, update, or remove records without restarting, use the HTTP API.

Resolution

phind resolves A, AAAA, and CNAME records locally, including chains:

api.phind → auth.phind → 127.0.0.1

Local records resolve first. Unknown names fall through to upstream DNS.

Results are cached in memory and cleared automatically when records are modified via the HTTP API.

Both UDP and TCP are supported on port 8053. TCP is used automatically by clients when a UDP response is truncated. This matters if you're routing real network traffic through phind, where large responses (DNSSEC, SPF, MX) can exceed the UDP limit.

Test resolution directly:

dig @127.0.0.1 -p 8053 app.dev

System-wide Resolution

phind listens on port 8053 by default and won't affect normal DNS until you point your system or network at it, making your naming layer available everywhere.

Router DNS is the simplest option. Point your router's DNS server at the machine running phind and every device on the network gets wildcard resolution, with everything else falling through upstream as usual. Note that if the machine running phind restarts, your network loses DNS until it comes back up.

dnsmasq forwarding is more surgical. Forward only your domains to phind and leave everything else alone:

# /etc/dnsmasq.conf
server=/.phind/127.0.0.1#8053
server=/.dev/127.0.0.1#8053

Explicit queries require no resolver config and are useful for testing:

dig @127.0.0.1 -p 8053 app.phind

Without one of the first two options, phind will only answer explicit queries.

HTTP API

Method Endpoint Description
GET /records List all records
POST /records Add or update a record
DELETE /records/{hostname} Remove a record
GET /resolve?name=auth.phind&type=A Resolve a name
GET /metrics Current metrics snapshot
GET /events SSE stream of metrics updates
GET /status Server status and record count
POST /cache/clear Flush cache

Records are posted as { "hostname": "*.dev", "entries": [...] }. Adding or removing a record clears the cache automatically.

Observability

phind tracks cache hits/misses, request latency, local vs. upstream resolution, failures, upstream forwards, and truncated upstream responses.

Metrics are kept in memory and flushed to a snapshot on an interval. The HTTP API reads from that snapshot, metrics writes are never in the DNS lookup path.

Access a snapshot:

GET /metrics

Stream live updates via SSE:

GET /events

The event stream emits a metrics event every second when anything has changed, including recent queries and the last 20 log entries. If nothing has changed, a keepalive ping is sent instead. Connect a dashboard or tail it with curl:

curl -N http://127.0.0.1:8080/events

Or export to an OTLP endpoint:

export PHIND_OTLP_ENDPOINT=http://localhost:4318/phind/events

Limitations

  • Requires a restart to pick up changes to the records file (use the HTTP API to manage records at runtime without restarting)

License

MIT

cr0w/phind 适用场景与选型建议

cr0w/phind 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「dns」 「local」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 cr0w/phind 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cr0w/phind 我们能提供哪些服务?
定制开发 / 二次开发

基于 cr0w/phind 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 33
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-28