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

Var Dumper Laravel Package

symfony/var-dumper

Symfony VarDumper provides a powerful dump() replacement for var_dump(), with smart variable inspection and rich output for debugging PHP applications. Walks complex data structures safely, improving readability and developer productivity.

View on GitHub
Deep Wiki
Context7

Provides mechanisms for walking through any arbitrary PHP variable

Frequently asked questions about Var Dumper
How do I use Symfony VarDumper in Laravel without extra dependencies?
Laravel already includes `symfony/var-dumper` via Composer. Just use `dump($variable)` or `dd($variable)` in your code—no installation required. These functions replace `var_dump()` and provide formatted, colorized output in both CLI and browser environments.
Can I customize how Eloquent models or Livewire components appear in `dump()` output?
Yes! Use `addDefaultCasters()` in a service provider to register custom casters for Eloquent models, Livewire components, or other Laravel objects. This lets you control how complex objects are displayed, like truncating long collections or hiding sensitive data.
Will `dump()` work in Laravel’s API routes when returning JSON responses?
Absolutely. VarDumper automatically detects the `Accept` header. If the request expects JSON (e.g., API calls), `dump()` will output JSON instead of HTML. This makes it seamless for debugging both web and API environments.
How do I restrict `dump()` usage to local environments only?
Wrap `dump()` calls in a check for the local environment: `if (app()->environment('local')) { dump($data); }`. For broader control, create middleware to block debug output in staging/production, or use `.env` to disable it entirely.
Does Symfony VarDumper support Laravel 10+ and PHP 8.4 features like enums?
Yes, Laravel 10+ uses Symfony 6.4+, so `symfony/var-dumper` v7.4+ supports PHP 8.4 features, including enums. However, older PHP versions (e.g., 8.1) may lack optimizations for newer types. Always check the [Symfony docs](https://symfony.com/doc/current/components/var_dumper/introduction.html) for version-specific notes.
Is there a performance impact if I use `dump()` in production-like staging environments?
VarDumper is lightweight for occasional use, but heavy debugging in staging can slow down requests. Mitigate this by restricting `dump()` to local environments or using `.env` to disable it in non-local contexts. Avoid running it in CI/CD pipelines unless absolutely necessary.
How do I mask sensitive data (e.g., passwords, tokens) in `dump()` output?
Use custom casters to filter sensitive fields. For example, create a caster for Eloquent models that replaces `password` or `api_token` with `[masked]`. Alternatively, use `VarDumper::setHandler()` to override the default output handler globally.
Can I use Symfony VarDumper in Laravel Artisan commands or queues?
Yes! `dump()` works in CLI contexts (e.g., Artisan commands) with colored terminal output. For queues, ensure the environment is set to `local` or use `app()->environment('local')` guards. Avoid dumping in production queues to prevent performance issues.
What’s the difference between `dump()` and `dd()` in Laravel?
`dump()` displays the variable and continues execution, while `dd()` (dump and die) stops script execution after displaying the output. Both use Symfony VarDumper under the hood. Use `dd()` for debugging critical failures where you need to halt execution.
Should I replace Laravel Debugbar or Ray with Symfony VarDumper?
VarDumper is a lightweight, built-in alternative for quick debugging with `dump()`/`dd()`, but tools like Debugbar or Ray offer more features (e.g., request inspection, query logging). Use VarDumper for variable inspection and pair it with other tools for comprehensive debugging.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony