anil / dump
A Laravel dump server package for intercepting and displaying dump output.
Requires
- php: ^8.2
- illuminate/config: ^11.0|^12.0|^13.0
- illuminate/console: ^11.0|^12.0|^13.0
- illuminate/http: ^11.0|^12.0|^13.0
- illuminate/log: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- symfony/var-dumper: ^7.0|^8.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.29
- mockery/mockery: ^1.6
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^4.0
- phpunit/phpunit: ^12.0
Suggests
- phpunit/phpunit: Required to use DumpFake testing utilities (^12.0)
This package is auto-updated.
Last update: 2026-05-08 01:25:38 UTC
README
A Laravel package that intercepts dump() and dd() calls and streams them to a dedicated terminal server — keeping your browser responses clean while you debug.
Inspired by Symfony's var-dump-server, built for the Laravel ecosystem.
Features
- Intercepts all
dump()/dd()calls and forwards them to a running terminal server - Falls back to CLI or HTML output when the server is not running
- Attaches request context (URI, method, controller) and a stack trace to every dump
- Optional log channel support — write every dump to a Laravel log channel
- Global helpers:
dump_if(),dump_unless(),dd_if(),dd_unless() DumpFaketesting utility with rich PHPUnit assertions- Production guard — the handler is never registered when
APP_ENV=production - Configurable clone depth and item limits via environment variables
Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.2 |
| Laravel | ^11.0 | ^12.0 | ^13.0 |
| symfony/var-dumper | ^7.0 | ^8.0 |
Installation
Install as a dev dependency (recommended — debug tooling should not ship to production):
composer require anil/dump --dev
If you need the dump server available in production (e.g. for staging environments or log-channel mirroring), install it as a regular dependency instead:
composer require anil/dump
The service provider is auto-discovered. Then run the install command to publish the config and add the required environment variables:
php artisan dump:install
This will:
- Publish
config/dump-server.php - Append
DUMP_SERVER_HOST,DUMP_SERVER_ENABLED, andDUMP_SERVER_LOG_ENABLEDto both.envand.env.example
Usage
1. Start the dump server
In a separate terminal, start the server before making requests:
php artisan dump:server
Output HTML instead of CLI output:
php artisan dump:server --format=html
2. Call dump() or dd() as usual
dump($user); dump(['key' => 'value']); dd($request->all());
When the server is running, output is captured and displayed in the server terminal — with request context and a stack trace — instead of inline in the browser.
When the server is not running, dump() falls back to normal CLI or HTML output.
Helper Functions
Four conditional helpers are available globally:
// Dump only when the condition is true dump_if($user->isAdmin(), $user); // Dump only when the condition is false dump_unless($request->isJson(), $request->all()); // Die-and-dump only when the condition is true dd_if(app()->isLocal(), $response); // Die-and-dump only when the condition is false dd_unless($feature->isEnabled(), $payload);
Configuration
Publish the config file manually if needed:
php artisan vendor:publish --tag=dump-server-config
config/dump-server.php:
return [ // TCP host the server listens on 'host' => env('DUMP_SERVER_HOST', 'tcp://127.0.0.1:9912'), // Set to false to disable the handler entirely in an environment 'enabled' => env('DUMP_SERVER_ENABLED', true), // VarCloner limits — increase for deeply nested structures 'max_depth' => env('DUMP_SERVER_MAX_DEPTH', 10), 'max_items' => env('DUMP_SERVER_MAX_ITEMS', 2500), // Optionally mirror every dump to a log channel 'log' => [ 'enabled' => env('DUMP_SERVER_LOG_ENABLED', false), 'channel' => env('DUMP_SERVER_LOG_CHANNEL', 'stack'), 'level' => env('DUMP_SERVER_LOG_LEVEL', 'debug'), ], ];
Environment variables
| Variable | Default | Description |
|---|---|---|
DUMP_SERVER_HOST |
tcp://127.0.0.1:9912 |
TCP address the server binds to |
DUMP_SERVER_ENABLED |
true |
Set to false to disable the handler |
DUMP_SERVER_MAX_DEPTH |
10 |
Maximum clone depth for nested objects |
DUMP_SERVER_MAX_ITEMS |
2500 |
Maximum number of items cloned |
DUMP_SERVER_LOG_ENABLED |
false |
Mirror dumps to a log channel |
DUMP_SERVER_LOG_CHANNEL |
stack |
Log channel to write to |
DUMP_SERVER_LOG_LEVEL |
debug |
PSR-3 log level |
Testing
The package ships with DumpFake, a drop-in test helper that captures dumps and provides PHPUnit assertions.
use Anil\Dump\Testing\DumpFake; $fake = DumpFake::fake(); dump('hello'); dump(42); dump(['a' => 1]); // Assert a specific value was dumped $fake->assertDumped('hello'); // Assert a value was NOT dumped $fake->assertNotDumped('world'); // Assert nothing was dumped $fake->assertNothingDumped(); // Assert the total number of dumps $fake->assertDumpedCount(3); // Assert using a custom callback $fake->assertDumpedUsing(fn ($v) => is_array($v) && isset($v['a'])); // Retrieve all captured values $dumped = $fake->getDumped(); // Restore the original handler when done $fake->restore();
Running the test suite
composer test
Static Analysis
The package is analysed at PHPStan level 10 with Larastan:
composer analyse
Code Style
Formatting is enforced with Laravel Pint:
composer format # fix composer format:check # check only
Changelog
See CHANGELOG.md for release history.
License
The MIT License (MIT). See LICENSE for details.