laravel / pao
Agent-optimized output for PHP testing tools
Requires
- php: ^8.3
- laravel/agent-detector: ^2.0.0
Requires (Dev)
- brianium/paratest: ^7.20.0
- laravel/pint: ^1.29.1
- orchestra/testbench: ^10.11.0 || ^11.1.0
- pestphp/pest: ^4.6.3 || ^5.0.0
- pestphp/pest-plugin-type-coverage: ^4.0.4 || ^5.0.0
- phpstan/phpstan: ^2.1.51
- rector/rector: ^2.4.2
- symfony/process: ^7.4.8 || ^8.1.0
- symfony/var-dumper: ^7.4.8 || ^8.0.8
Conflicts
- laravel/framework: <12.0.0
- nunomaduro/collision: <8.9.3
- pestphp/pest: <4.6.3 || >=6.0.0
- phpunit/phpunit: <12.5.23 || >=13.0.0 <13.1.7 || >=14.0.0
README
Introduction
Laravel PAO is agent-optimized output for PHP tools. It works with any PHP project — Laravel, Symfony, Laminas, vanilla PHP, or anything else that uses PHPUnit, Pest, Paratest, PHPStan, or Laravel Artisan.
It detects when your tools are running inside an AI agent — Claude Code, Cursor, Devin, Gemini CLI, and others — and replaces the verbose, human-readable output with compact, super minimal, structured JSON. For Laravel Artisan commands, it strips ANSI colors, box-drawing characters, and excess whitespace. Zero config — just install and it works.
Installation
Requires PHP 8.3+ — Works with PHPUnit 12-13, Pest 4-5, Paratest, PHPStan, and Laravel 12+.
composer require laravel/pao --dev
That's it. PAO hooks into PHPUnit, Pest, Paratest, and PHPStan automatically through Composer's autoloader. For Laravel projects, a service provider is auto-discovered to clean Artisan command output.
PAO only activates when it detects an AI agent (Claude Code, Cursor, Devin, Gemini CLI, etc.). When you or your team run tools directly in the terminal, the output is completely unchanged — same colors, same formatting, same experience. Zero impact on human workflows.
Before & After
Your test suite with 1,000 tests goes from this:
PHPUnit 12.5.14 by Sebastian Bergmann and contributors.
............................................................. 61 / 1002 ( 6%)
............................................................. 122 / 1002 ( 12%)
...
.......................... 1002 / 1002 (100%)
Time: 00:00.321, Memory: 46.50 MB
OK (1002 tests, 1002 assertions)
To this:
{
"tool": "phpunit",
"result": "passed",
"tests": 1002,
"passed": 1002,
"duration_ms": 321
}
That's up to 99.8% fewer AI tokens. The output is constant-size regardless of how many tests you have — and when tests fail, it includes file paths, line numbers, and failure messages.
Extra output from Pest plugins like --coverage or --profile is captured, cleaned of ANSI codes and decorations, and included as a raw array in the JSON:
{
"tool": "pest",
"result": "passed",
"tests": 1002,
"passed": 1002,
"duration_ms": 1520,
"raw": [
"Http/Controllers/Controller 100.0%",
"Models/User 0.0%",
"Total: 33.3 %"
]
}
Laravel Artisan
When installed in a Laravel 12+ application, PAO automatically cleans Artisan command output in agent environments — stripping ANSI colors, box-drawing characters, dot separators, and excess whitespace:
# Before (without PAO) — 2,111 characters
Environment ................................................................
Application Name ................................................... Laravel
Laravel Version ..................................................... 13.3.0
PHP Version .......................................................... 8.5.4
Debug Mode ......................................................... ENABLED
# After (with PAO) — 535 characters
Environment ..
Application Name .. Laravel
Laravel Version .. 13.3.0
PHP Version .. 8.5.4
Debug Mode .. ENABLED
Up to 75% fewer tokens on commands like about, db:show, and migrate:status — same information, no decoration.
PHPStan
PHPStan output is also converted to structured JSON:
{
"tool": "phpstan",
"result": "failed",
"errors": 2,
"error_details": {
"/app/Http/Controllers/Controller.php": [
{
"line": 9,
"message": "Method Controller::index() should return int but returns string.",
"identifier": "return.type"
},
{
"line": 14,
"message": "Call to an undefined method Controller::doesNotExist().",
"identifier": "method.notFound"
}
]
}
}
Contributing
Thank you for considering contributing to Laravel! The contribution guide can be found in the Laravel documentation.
Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
License
The Laravel PAO is open-sourced software licensed under the MIT license.
