承接 gaoqi/php-tuic-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

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

CI Native Release Packagist Version License PHP

中文文档

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
  • doctor and run CLI 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-ffi
  • ext-json
  • ext-openssl
  • ext-sockets
  • a loadable libquiche shared library

Install

composer require 18230/php-tuic-client

Official release tags vendor prebuilt libquiche binaries for:

  • windows-x64
  • linux-x64
  • macos-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 name
  • type: must be tuic
  • server: remote TUIC server hostname or IP
  • port: remote TUIC port
  • uuid: TUIC user UUID
  • password: TUIC password / token
  • alpn: usually [h3]
  • sni: TLS server name

Supported optional fields:

  • skip-cert-verify: defaults to false
  • disable-sni: defaults to false
  • reduce-rtt: defaults to false
  • udp-relay-mode: parsed but UDP relay is not implemented yet
  • congestion-controller: typically bbr

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 log
  • status-file: JSON snapshot of listener, node, and counters
  • pid-file: current process ID

The status-file includes counters such as:

  • accepted_connections_total
  • closed_connections_total
  • handshake_timeouts_total
  • tuic_auth_success_total
  • tuic_auth_failure_total

Production Notes

  • Keep the SOCKS5 listener on loopback unless you truly need LAN access.
  • Run doctor against 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, and pid-file.
  • If you deploy on another architecture, ship your own libquiche with the same artifact and either place it under the matching triplet directory or set QUICHE_LIB.
  • Prefer Linux for long-running production workloads.

Troubleshooting

  • doctor fails before startup: Run php bin/tuic-client doctor ... with the exact PHP binary you will use in production.
  • ext-ffi is disabled: Enable FFI in php.ini, then rerun doctor.
  • libquiche cannot be found: Use the tagged release package or point QUICHE_LIB / --quiche-lib at the absolute library path.
  • The process starts but local requests fail: Check log-file and status-file first. If tuic_auth_failure_total is 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 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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