Skip to main content

Introduction

laravel/pao is a package that optimizes the output of PHP development tools for AI agents. PAO (PHP Agent-Optimized output) automatically transforms verbose output from PHPUnit, Pest, Paratest, PHPStan, and Laravel Artisan into structured, compact JSON. As many AI agents including GitHub Copilot have moved to token-based pricing, reducing tool output directly translates to cost savings. PAO is designed to solve exactly this problem and is planned to be included by default in the Laravel starter kits.

Why it matters

As AI agents become deeply embedded in the development flow, tool output token count directly affects cost and response time. In a project with 1,000 tests, PHPUnit’s output can be thousands of lines, but all an AI agent needs is “success/failure, counts, and where things failed.” PAO compresses this into a single-digit JSON object.
  • Test output: up to 99.8% token reduction
  • PHPStan output: structured JSON containing only what’s needed
  • Artisan output: strips ANSI codes, box-drawing characters, and whitespace for up to 75% reduction

Installation

Requires PHP 8.3+, PHPUnit 12-13 / Pest 4-5 / Paratest / PHPStan / Laravel 12+.
It works after installation—no further setup. PAO auto-hooks into PHPUnit, Pest, Paratest, and PHPStan via Composer’s autoloader. In Laravel projects, the service provider is auto-discovered and Artisan output optimization is also enabled.
PAO only activates when an AI agent environment is detected. When a human runs commands directly in a terminal, it’s completely disabled and normal output is preserved.

Supported AI agents

PAO auto-detects the following AI agents.

Before / after

Test output (PHPUnit / Pest)

A 1,000-test suite is transformed like this. Before (without PAO)
After (with PAO)
Regardless of test count, the output stays a constant size. When tests fail, file paths, line numbers, and failure messages are included.

Coverage and other plugin output

Additional output from Pest plugins like --coverage or --profile is stripped of ANSI codes and decorations and included in a raw array.

PHPStan output

Laravel Artisan output

Command output like php artisan about has ANSI codes, box-drawing characters, dot separators, and extra whitespace stripped. Before (without PAO) — 2,111 characters
After (with PAO) — 535 characters
Expect up to 75% token reduction for commands like about, db:show, and migrate:status.

Integration with Laravel starter kits

PAO is planned to be included by default in the Laravel starter kits. Creating a new project will install it automatically, letting you start AI-agent-driven development with lower token costs from day one.

Summary

laravel/pao works just by installing, and activates only in AI agent environments—so it doesn’t affect your existing development workflow at all. It’s worth adopting in any PHP/Laravel project where you want to reduce AI agent development costs.

laravel/pao repository

Source code and the latest list of supported tools and agents.
Last modified on July 13, 2026