Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Dumper Laravel Package

spiral/dumper

High-performance PHP variable dumper for the Spiral framework. Provides readable, developer-friendly dumps for debugging in CLI or web, with clean formatting and easy integration into your app to inspect arrays, objects, and complex data structures.

View on GitHub
Deep Wiki
Context7

Getting Started

Install via Composer:

composer require spiral/dumper

In your PHP code, simply use the Spiral\Dumper\Dumper class to output variables with syntax highlighting and structure folding:

use Spiral\Dumper\Dumper;

$dumper = new Dumper();
$dumper->dump($myVariable); // Outputs to stdout with CLI coloring

For web contexts, enable HTML output by setting the FORMAT env or using the factory:

$dumper = Dumper::createHtml(); // Automatically formats for browser with CSS
$dumper->dump($data);

Check README.md in the repo for basic CLI usage, color customization, and configuration examples.

Implementation Patterns

  • Debugging in Console Scripts: Use Dumper::createCli() for terminal-friendly, colorized output; integrates well with Symfony Console.
  • Dev-Only Dumping: Wrap dumps in a app()->isDebug() check to avoid shipping debug output in production.
  • Log Integration: Pipe dumper output into log channels by capturing via dump_to_stream() or using MemoryDumper to collect output before writing to logs.
  • Testing Helpers: In PHPUnit tests, capture dumped output using Dumper::capture() and assert structure/content for integration scenarios.
  • Configuration via Environment: Set DUMPER_FORMAT=html or DUMPER_THEME=dark to globally affect behavior without code changes.

Gotchas and Tips

  • Output Buffering Conflicts: If using Dumper inside a CLI command that already manipulates output (e.g., Symfony’s OutputInterface), avoid calling dump() directly—capture to string and manually write.
  • Memory Overhead: dump() outputs directly to php://stdout/php://output; large objects may flush buffers unexpectedly—prefer dumpToString() for safe inspection.
  • No HTML Auto-Encoding: HTML dumps are not escaped; never dump untrusted user input in production-facing contexts—risk of XSS if output reaches browser.
  • Theme Customization: Extensible via custom themes (JSON files); define your own color palette in config/dumper.php and reference via theme: 'mytheme'.
  • Subtree Split Quirks: Since this is a subtree split of spiral/framework, some internal classes may rely on tightly coupled Spiral components—avoid relying on internal Dumper\Renderer\* unless prepared for version-skew.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation