gaoqi/php-tuic-client
Composer 安装命令:
composer require gaoqi/php-tuic-client
包简介
Pure PHP TUIC client with a local SOCKS5 proxy runtime backed by cloudflare/quiche FFI.
README 文档
README
php-tuic-client is a pure PHP TUIC v5 client focused on one job: start a local socks5://127.0.0.1:1080 style proxy and relay it through a TUIC node.
The QUIC transport is provided by cloudflare/quiche through PHP FFI. The local accept loop, node parsing, CLI flow, and runtime control stay in PHP.
Scope
- TUIC v5 authentication
- local SOCKS5 server
- Clash-style YAML / JSON node parsing
- Windows, Linux, and macOS project support
- cross-platform startup scripts
doctorandrunCLI workflow- compatibility request helpers for framework projects, built on top of the same local SOCKS5 runtime
Not in scope right now:
- UDP relay
- HTTP proxy runtime
- multi-node scheduling
Requirements
- PHP
8.2.4+ ext-ffiext-jsonext-opensslext-sockets- a loadable
libquicheshared library
Install
composer require 18230/php-tuic-client
Official release tags vendor prebuilt libquiche binaries for:
windows-x64linux-x64macos-x64
That means a normal composer require from a tagged release can use the bundled shared library directly. If you install from dev-main or run on another architecture, build your own library and point QUICHE_LIB or --quiche-lib at it.
Build libquiche
Official releases already include prebuilt x64 libraries. Build manually only if you are developing locally, using dev-main, or targeting another architecture.
You need a shared quiche build with the ffi feature enabled.
Windows:
.\scripts\build-quiche.ps1
Linux / macOS:
./scripts/build-quiche.sh
If your library lives outside the default search locations, point QUICHE_LIB or --quiche-lib to the absolute path.
Quick Start
Validate runtime prerequisites:
php bin/tuic-client doctor --config=examples/node.example.yaml
The doctor command prints the detected native triplet and the library search order. On official release installs it should resolve the bundled file under resources/native/<platform>-<arch>/.
Start with inline YAML:
php bin/tuic-client \
--node="{ name: 'SG 01', type: tuic, server: your-tuic-server.example.com, port: 443, uuid: 11111111-1111-1111-1111-111111111111, password: your-password, alpn: [h3], disable-sni: false, reduce-rtt: false, udp-relay-mode: native, congestion-controller: bbr, skip-cert-verify: false, sni: your-tuic-server.example.com }" \
--listen=127.0.0.1:1080
Or start from a config file:
php bin/tuic-client --config=examples/node.example.yaml --listen=127.0.0.1:1080
Then point your tools at:
socks5://127.0.0.1:1080
For command-line tools, prefer socks5h:// so DNS resolution also goes through the proxy:
curl --proxy socks5h://127.0.0.1:1080 https://api.ipify.org?format=json
Examples:
<?php $ch = curl_init('https://api.ipify.org?format=json'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_PROXY => '127.0.0.1:1080', CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5_HOSTNAME, ]); echo curl_exec($ch); curl_close($ch);
Node Fields
Required TUIC node fields:
name: local display nametype: must betuicserver: remote TUIC server hostname or IPport: remote TUIC portuuid: TUIC user UUIDpassword: TUIC password / tokenalpn: usually[h3]sni: TLS server name
Supported optional fields:
skip-cert-verify: defaults tofalsedisable-sni: defaults tofalsereduce-rtt: defaults tofalseudp-relay-mode: parsed but UDP relay is not implemented yetcongestion-controller: typicallybbr
Minimal example:
proxies: - name: demo-tuic type: tuic server: example.com port: 443 uuid: 00000000-0000-4000-8000-000000000000 password: replace-with-your-password alpn: [h3] sni: example.com
CLI
Main options:
--node--config--node-name--listen--allow-ip--max-connections--connect-timeout--idle-timeout--handshake-timeout--status-file--status-interval--log-file--pid-file--quiche-lib--dry-run
Production-style example:
php bin/tuic-client \ --config=/opt/php-tuic-client/config/tuic.yaml \ --listen=127.0.0.1:1080 \ --allow-ip=127.0.0.1 \ --max-connections=2048 \ --connect-timeout=12 \ --idle-timeout=600 \ --handshake-timeout=20 \ --status-file=/opt/php-tuic-client/runtime/status.json \ --log-file=/opt/php-tuic-client/runtime/proxy.log \ --pid-file=/opt/php-tuic-client/runtime/proxy.pid
Node Example
proxies: - name: demo-tuic type: tuic server: example.com port: 443 uuid: 00000000-0000-4000-8000-000000000000 password: replace-with-your-password alpn: [h3] disable-sni: false reduce-rtt: false udp-relay-mode: native congestion-controller: bbr skip-cert-verify: false sni: example.com
Runtime Outputs
When you run the proxy in production, these files are the most useful:
log-file: human-readable runtime logstatus-file: JSON snapshot of listener, node, and counterspid-file: current process ID
The status-file includes counters such as:
accepted_connections_totalclosed_connections_totalhandshake_timeouts_totaltuic_auth_success_totaltuic_auth_failure_total
Production Notes
- Keep the SOCKS5 listener on loopback unless you truly need LAN access.
- Run
doctoragainst the exact PHP binary that will host the long-running process. - Official release tags already ship bundled x64 native libraries inside the Composer package.
- Production flags stay intentionally small and explicit:
allow-ip,max-connections,connect-timeout,idle-timeout,handshake-timeout,status-file,log-file, andpid-file. - If you deploy on another architecture, ship your own
libquichewith the same artifact and either place it under the matching triplet directory or setQUICHE_LIB. - Prefer Linux for long-running production workloads.
Troubleshooting
doctorfails before startup: Runphp bin/tuic-client doctor ...with the exact PHP binary you will use in production.ext-ffiis disabled: Enable FFI inphp.ini, then rerundoctor.libquichecannot be found: Use the tagged release package or pointQUICHE_LIB/--quiche-libat the absolute library path.- The process starts but local requests fail:
Check
log-fileandstatus-filefirst. Iftuic_auth_failure_totalis non-zero, verify node credentials, SNI, and TLS settings. - Windows / Linux / macOS mismatch: Make sure the packaged native library matches the current platform and architecture.
Framework Helpers
The package still ships TuicRequestClient and framework service providers for Laravel / ThinkPHP. These helpers are convenience layers built on top of the same local SOCKS5 runtime plus cURL. They are optional and not required if you only want the protocol-level local proxy.
More detail:
Testing
composer test
php bin/tuic-client --config=examples/node.example.yaml --dry-run
php bin/tuic-client doctor --config=examples/node.example.yaml
The release pipeline also runs a real-node end-to-end probe on ubuntu-22.04, windows-latest, and macos-15-intel using the packaged libquiche binaries and a local socks5://127.0.0.1:11084 listener.
gaoqi/php-tuic-client 适用场景与选型建议
gaoqi/php-tuic-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「proxy」 「socks5」 「ffi」 「quic」 「tuic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gaoqi/php-tuic-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gaoqi/php-tuic-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gaoqi/php-tuic-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Lazy loading for middleware and request handlers
Async SOCKS proxy connector client and server implementation, tunnel any TCP/IP-based protocol through a SOCKS5 or SOCKS4(a) proxy server, built on top of ReactPHP.
A simple SOCKS5 tcp client
SOCKS5 proxy connector for tunneling TCP connections (RFC 1928)
Get working public proxy list for free by PubProxy (No API key required).
Alfabank REST API integration
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-29