Laravel 5.7 new update includes supports of Symfony’s dump server command.
If you run php artisan command on your laravel 5.project you will see new command called dump-server and it says “Start the the dump server to collect dump information”
So basically the dump server command help us to see details dump information on terminal itself without affecting the web page. all we can say is – It is a quick way to have details right in front of the developer without reflecting to the user.
Let’s see how you can use dump server.
Dump Server Example:
Open your routes file and add dump information to the welcome page route section as showing below.
<?php
Route::get('/', function () {
$sampleArray = ['one', 'two', 'three'];
dump($sampleArray);
return view('welcome');
});
Now browse the page and you will see the dump information now being showed on the browser, this how we usefully used to do till laravel 5.6 framework.
But now here is the main demonstration on dump server implementation comes into place.
Also Read – How to Enable Laravel 5.7 Email Verification Support
Execute dump Server:
Go ahead and open terminal or command prompt if your on windows and execute dump server command.
$ php artisan dump-server
You will see following interface of dump server listener, it says that the dump server is running and you can quit using Control + C.
Now open your browser and refresh the same page. you will see that the it removes the dump information from the page.
And now you can checkout the terminal, the dump server caches the details dump information along with the times stamp and the file were it was executed.
Useful right? as a developer I often see many times I used to dump the information it is used to lock within the html tags and has to look out the page source to see in details. instead now we can use the dump server the easiest way to figure out what happening with the code.
One more thing the dump server will also work for die dump function that is dd(); and off course when you do that it will kill the execution further from dd function.
Cool feature right 🙂 so keep using while you do programming.