Improve Debugging Output With Laravel Dumper
Published on by Paul Redmond
The Laravel dumper package improves on the default dumper with useful Laravel-specific enhancements.
Alright. I just tagged the first stable pre-release of Laravel Dumper: https://t.co/iLrBk51gxG
— Chris #BlackLivesMatter (@inxilpro) January 19, 2022
Just `composer require` and instantly get improved `dd()` and `dump()` output for most Laravel core classes (like Models, Query Builders, the Service Container, etc). pic.twitter.com/tYSwx270O9
You’ll get helpful information for various core Laravel objects, such as:
- Models
- Query Builders
- Service Container
- Database Connections
- Carbon Instances
- Requests and Responses
Take this simple Post
model query, for example, which conveniently outputs the query builder SQL query at the top:
Illuminate\Database\Eloquent\Builder {#332 sql: "select `title` from `posts` where `id` = '1'" #connection: Illuminate\Database\MySqlConnection {#334 ▶} #model: App\Models\Post {#320 …} #eagerLoad: [] …5}
You can expect enhanced output automatically wherever you typically use dd()
and even get the experience with chaining dd()
calls onto the query builder. For example:
Post::query()->select('title')->where('id', 1)->dd();
Would output something like the following:
If you still want to access the original default dump/dd behavior, you can use the following helper functions:
// f = fullddf();dumpf();
If you’d like to learn more about the difference between the default experience and the enhancements made by the dumper package, check out the Laravel Dumper diffs on GitHub.
You can learn more about this package, get full installation instructions, and view the source code on GitHub.