Improve Debugging Output With Laravel Dumper


January 25th, 2022

Improve Debugging Output With Laravel Dumper

The Laravel dumper package improves on the default dumper with useful Laravel-specific enhancements.

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: []

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:

Laravel Dumper query dump example

If you still want to access the original default dump/dd behavior, you can use the following helper functions:

// f = full

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.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.