Laravel Dump Server is a package by Marcel Pociot, which brings Symfony’s Var-Dump Server to Laravel.
Instead of dumped data messing up the response, a dedicated “Dump server” console collects dumped data which is sent to stdout, or piped to a file:
# Symfony Example >= Symfony 4.1 ./bin/console server:dump # Artisan example using the Laravel Dump Server package php artisan dump-server
dd() command is what I grab, but being able to dump output at certain points without
die()ing seems like an excellent workflow!
After I learned about this package, I submitted a pull request to support HTML output which you can pipe to an HTML file instead. If the pull request is accepted, you could specify the HTML output format which is pretty neat in my opinion:
php artisan dump-server --format=html > dump.html
After piping the output to
dump.html, you can continue to refresh your application and get updated output in the HTML file that you can see by refreshing. The example output would look like this (notice that the Illuminate
HtmlDumper class is used to give the output the Laravel treatment):
Please note that piping to HTML isn’t available at the time of writing, but I’ll update this post if the HTML formatting option is accepted.
Update: Piping output to HTML is now available in the latest version!
How Does this Work?
In the background, Symfony provides a dedicated server to collect dumped data via
DumpServer. When you call
dump in your application code while the server is running, the dumped data is sent to the centralized server that outputs to the console.
When the dump server is not running,
dump() works just like you’d expect by default.
You can learn more about and download the Laravel Server Dumper package on GitHub. Star the package and share it with your friends.
If you love Laravel, you should support Marcel Pociot in his open-source efforts in any way you can! He’s putting out some quality work, plus has given us BotMan to help make developing chatbots a breeze with your favorite tools.
Over the last couple of weeks, Marcel has been on Laravel News four times, with open-source and Laravel-specific contributions:
- Learn Laravel Forge a free screencast series by Marcel on Laracasts
- Laravel Self-diagnosis package a package to diagnose your Laravel app setup
- Entity Relation Diagram generator to generate a diagram of your Laravel model relationships
- Laravel Test Tools updates that enable you to create Laravel Dusk test cases in Google Chrome.
Filed in: News
Join the weekly newsletter and never miss out on new tips, tutorials, and more.
- Senior Full-Stack Developer (PHP+JS)
The Interaction Design Foundation
- Senior Laravel Developer
- Laravel / Vue.JS Developer - Join an amazing team!
- Mid / Sen. Software Engineer
- Remote PHP / Laravel Developer
- Senior PHP/Laravel Developer: Your Dream Work Environment
iPhone Photography School
- Senior Laravel Developer
PHP 7 Multi-format Streaming Parser
PHP 7 Stream Parser is a package by Sergio Ródenas for PHP multi-format stream parsing. Using streams with a pull par…
Twine: String Manipulation, Leveled Up
Twine is a stand-alone PHP 7 package by Chris Kankiewicz for string manipulation and comparison with an expressive fl…