- Is symfony/var-dumper already included in Laravel?
- Yes. Laravel ships symfony/var-dumper as a transitive dependency of laravel/framework, which uses it to back the dump() and dd() helpers and the debug exception renderer. You normally do not need to install it separately in a Laravel application. Treat it as an incumbent component to standardize and govern rather than a new package to evaluate.
- How do I install symfony/var-dumper in a Laravel project?
- In a normal Laravel app it is already present, so you can call dump() and dd() without adding anything to composer.json. If you are working in a standalone PHP project or a stripped-down install, run composer require symfony/var-dumper and load Composer's autoloader. The package has a tiny footprint and registers the global dump() and dd() functions through its files autoload entry.
- What is the difference between dump() and dd() in Laravel?
- dump() outputs a structured, syntax-highlighted representation of one or more variables and lets execution continue. dd() performs the same dump but then terminates the request, which makes it useful for quick inspection but dangerous in tests or shared environments. Both helpers are backed by symfony/var-dumper and accept multiple arguments.
- Which Laravel and PHP versions support symfony/var-dumper?
- The version you get is dictated by your Laravel version because Laravel pulls it in as a dependency. Symfony maintains parallel 5.4, 6.4, 7.4, and 8.x branches, and Symfony 8 requires PHP 8.4 or newer. The API surface used by Laravel, including dump(), dd(), VarDumper::setHandler(), and VarDumper::addCaster(), has been stable across 5.4 through 8.1.
- How do I limit dump depth or change the output format in Symfony VarDumper?
- VarDumper uses pluggable dumpers such as CliDumper and HtmlDumper, and you can configure depth and formatting on the active dumper. Register a custom handler with VarDumper::setHandler() when you need consistent output for CLI, browser, or server-based debugging. Depth control is especially useful for large arrays and Eloquent object graphs that would otherwise produce huge dumps.
- Can I add custom casters for Eloquent models or DTOs in VarDumper?
- Yes. VarDumper exposes an additive extension seam through VarDumper::addCaster() and AbstractCloner::addDefaultCasters(), which you can bind in a Laravel service provider. Custom casters let you present domain objects, value objects, and DTOs in a compact, intentional shape instead of exposing raw internals. Assign ownership for those casters so they stay aligned with model and DTO changes.
- Is symfony/var-dumper safe to use in production?
- It is a debugging tool, so dumps should be treated as a security boundary whenever attacker-influenced data such as request payloads, headers, or user strings can be rendered. The 5.4.54 security release fixed escaping of UTF-8 C1 control characters in HtmlDescriptor and terminal context strings, showing that output escaping is security-relevant. Keep dump() and dd() out of non-local environments through handler configuration, static analysis, or both.
- Why does dump() output HTML in some requests and plain text in others?
- Newer Symfony releases select HtmlDumper only when the Accept header contains html, with follow-up fixes for Accept: */* and application/json requests in patch releases such as 7.4.3 and 8.0.3. CLI contexts use CliDumper instead. This behavior can silently break test assertions or corrupt JSON API responses if a stray dump() survives, so validate it against your API suite during Laravel upgrades.
- Can I use the Symfony dump server with a Laravel application?
- Yes. VarDumper includes ServerDumper and a dump-server workflow that can collect dumps from CLI and browser contexts, and it can fit a shared Docker Compose development environment. It is optional for basic Laravel debugging and should be secured if other developers or CI need to reach it. Decide whether CI actually needs dump-server access before adding it to the standard dev stack.
- What are alternatives to symfony/var-dumper for Laravel debugging?
- Common alternatives include Ray, Laravel Debugbar, and tuning Xdebug settings such as var_display_max_depth. Those tools can be useful, but they add another debugging dependency and adoption tax compared with the VarDumper component Laravel already ships. For most teams the cheaper path is to standardize VarDumper usage, add custom casters, and block dump() and dd() outside local environments.