PAO:PHP 测试工具的代理优化输出
最后更新于 经过 保罗·雷德蒙德
PAO by Nuno Maduro is a dev tool that detects when your tests are running inside an AI agent — Claude Code, Cursor, Devin, Gemini CLI — and replaces the normal test runner output with compact JSON. The result is a fraction of the token count, with no change to how you run your tests.
工作原理
PAO hooks into PHP's autoloader. Once installed, it automatically detects AI agent environments and switches from the test runner's default human-readable output to a minimal JSON format:
{
“结果”
:
"passed"
,
"tests"
:
1002
,
"passed"
:
1002
,
"duration_ms"
:
321}
That output is constant at roughly 20 tokens regardless of how large your test suite is.
Token Reduction
The benchmarks from a 1,000-test suite show a significant difference:
| Runner | Without PAO | With PAO | Reduction |
|---|---|---|---|
| PHPUnit | 336 tokens | 20 tokens | 94% |
| 害虫 | 10,123 tokens | 20 tokens | 99.8% |
| Pest (parallel) | 11,125 tokens | 20 tokens | 99.8% |
Beyond the per-run savings, the bigger benefit in longer agentic sessions is context window preservation. Test output that would otherwise accumulate over dozens of runs no longer competes with code and conversation history.
Framework and Runner Support
PAO works with PHPUnit 12–13, Pest 4–5, and Paratest. It's not Laravel-specific — any PHP project using one of those runners (Laravel, Symfony, Laminas, vanilla PHP) gets the same behavior.
安装
PAO requires PHP 8.3 or higher. No config file, no service provider, no additional setup — activation happens through Composer's autoloader automatically.
作曲家
要求
nunomaduro/pao:0.x-dev
--dev
Note that the package is a work in progress under active development.
您可以在以下位置找到来源: GitHub 。






