nunomaduro/collision
Collision provides beautiful, developer-friendly CLI error reporting for PHP apps. Built on Whoops and included with Laravel, it integrates with Symfony, PHPUnit, and more to show rich stack traces and context when exceptions happen.
Collision is a drop-in error handler for CLI PHP applications, especially prominent in Laravel (via php artisan). Its primary value is transforming cryptic PHP errors into beautifully rendered, context-rich stack traces—complete with code snippets, syntax highlighting, and helpful suggestions.
First steps:
composer require nunomaduro/collision --devphp artisan commands will automatically use it.(new \NunoMaduro\Collision\Provider)->register();
First use case: Run a broken Artisan command like php artisan make:controller with an invalid namespace—watch Collision turn a messy FatalError into a clean, colorized output with line highlights and actionable hints.
Collision integrates natively with Laravel’s console kernel and command resolution. Beyond that, it shines in testing, custom CLI tools, and Laravel Zero apps.
Common workflows:
php artisan. Its error screen appears even for uncaught exceptions, handler exceptions, or validation errors.register call in phpunit.xml bootstrap or Pest.php / bootstrap/app.php to enhance test output. Example in a test bootstrap:
if (class_exists(\NunoMaduro\Collision\Provider::class)) {
(new \NunoMaduro\Collision\Provider)->register();
}
bootstrap/app.php, just before $app->run(). This ensures all command errors are rendered consistently.$application = new Application();
(new \NunoMaduro\Collision\Provider)->register();
$application->run();
Pro tip: Use --no-ansi or TERM=dumb to disable Colorful output for CI logs or tools like Laravel Horizon that may misrender ANSI sequences.
app/Exceptions/Handler.php hasn’t overridden the console exception rendering in a way that bypasses Collision (e.g., renderForConsole() returning early).nunomaduro/termwind for rendering. If your project limits dependencies, be aware of this transitive requirement—especially in containerized or minimal environments.php artisan vendor:publish --provider="NunoMaduro\Collision\CollisionServiceProvider") to tweak themes (e.g., dark, light, catppuccin), max frames, or disable hints.php artisan --version → confirms Collision is activeWHOOPS_ENABLE or SHELL_VERBOSITY settings interfereAdapter to inject domain-specific context into error hints. See src/Adapters/Laravel/ for examples.How can I help you explore Laravel packages today?