PHPackages                             cerbero/sql-dumper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. cerbero/sql-dumper

ActiveLibrary[Database &amp; ORM](/categories/database)

cerbero/sql-dumper
==================

Laravel package to dump SQL queries.

1.2.0(5y ago)247.6k↓50%3MITPHPPHP ^7.1||^8.0

Since May 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/cerbero90/sql-dumper)[ Packagist](https://packagist.org/packages/cerbero/sql-dumper)[ Docs](https://github.com/cerbero90/sql-dumper)[ RSS](/packages/cerbero-sql-dumper/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (10)Versions (5)Used By (0)

SQL Dumper
==========

[](#sql-dumper)

[![Author](https://camo.githubusercontent.com/fffbc89ca2742dccf8be167716e04b7125a913abae0da6a488131999dab8ca25/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d617574686f72266d6573736167653d6365726265726f393026636f6c6f723d353041424631266c6f676f3d74776974746572267374796c653d666c61742d737175617265)](https://twitter.com/cerbero90)[![PHP Version](https://camo.githubusercontent.com/54752be0148a2435442a5f7f0e296873e161efd71d80f926c12fc6f2018a4bb3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6365726265726f2f73716c2d64756d7065723f636f6c6f723d253233344635423933266c6f676f3d706870267374796c653d666c61742d737175617265)](https://www.php.net)[![Laravel Version](https://camo.githubusercontent.com/4c2e5da6aec07bd5538de60b57e9774042431d47e1f18b5d3434cde68853ca4a/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d6c61726176656c266d6573736167653d254532253839254135352e3626636f6c6f723d666632643230266c6f676f3d6c61726176656c267374796c653d666c61742d737175617265)](https://laravel.com)[![Build Status](https://camo.githubusercontent.com/3efe5331c5df280ffc833fbda43a5e35eb2847a6ceb7231bd65df8cbb8d62e26/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6365726265726f39302f73716c2d64756d7065722f6275696c643f7374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://github.com/cerbero90/sql-dumper/actions?query=workflow%3Abuild)[![Coverage Status](https://camo.githubusercontent.com/1e09494e6d31daeb971cdd3583b2fe539ecfb67c7673760a10658c898cbbe36d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6365726265726f39302f73716c2d64756d7065722e7376673f7374796c653d666c61742d737175617265266c6f676f3d7363727574696e697a6572)](https://scrutinizer-ci.com/g/cerbero90/sql-dumper/code-structure)[![Quality Score](https://camo.githubusercontent.com/83d2ee3301d489f1954bb918ad72e2161aa0aa7190196a100373932d5b6b436a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6365726265726f39302f73716c2d64756d7065722e7376673f7374796c653d666c61742d737175617265266c6f676f3d7363727574696e697a6572)](https://scrutinizer-ci.com/g/cerbero90/sql-dumper)[![Latest Version](https://camo.githubusercontent.com/dbca07da9dfc73c187ad1506efdc1b580fd5eab5bba73679d634566bdd3deaf4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6365726265726f2f73716c2d64756d7065722e7376673f6c6162656c3d76657273696f6e267374796c653d666c61742d737175617265)](https://packagist.org/packages/cerbero/sql-dumper)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![PSR-12](https://camo.githubusercontent.com/9ba5754b3504e97a10e2b2f84770a218e69e544e9de8943eceb0b67599c83c6c/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d636f6d706c69616e6365266d6573736167653d5053522d313226636f6c6f723d626c7565267374796c653d666c61742d737175617265)](https://www.php-fig.org/psr/psr-12/)[![Total Downloads](https://camo.githubusercontent.com/6733b3904c6bfba7f9f0e9fc6a6a73b863f66da01c8f8f4d47732191a94cbc04/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6365726265726f2f73716c2d64756d7065722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cerbero/sql-dumper)

Laravel package to dump SQL queries, related `EXPLAIN` and location in code in different formats:

- HTML
- markdown
- email
- console
- log

Install
-------

[](#install)

Via Composer

```
composer require --dev cerbero/sql-dumper
```

To customize some aspects of this package, the `config/sql_dumper.php` file can optionally be generated via:

```
php artisan vendor:publish --tag=sql-dumper
```

Usage
-----

[](#usage)

The easiest way to dump a SQL query is calling the helper functions. There is a helper for each dumper:

- `ds()` dump SQL queries with the dumper specified in `config/sql_dumper.php` as default dumper
- `dsConsole()` dump SQL queries with the console dumper
- `dsEmail()` dump SQL queries with the email dumper
- `dsHtml()` dump SQL queries with the html dumper
- `dsLog()` dump SQL queries with the log dumper
- `dsMarkdown()` dump SQL queries with the markdown dumper

All SQL queries executed within the helper's closure are dumped:

```
$user = ds(function () {
    return User::with('posts')->find(1);
});
```

Depending on dumper and database driver, SQL queries dumps will look like:

 console dump [![](images/console_dump.png)](images/console_dump.png) email or HTML file or markdown file dump [![](images/html_dump.png)](images/html_dump.png) log file dump [![](images/log_dump.png)](images/log_dump.png)---

Along with the default dumper, in `config/sql_dumper.php` we may customize the SQL dumpers default behavior. For example, the HTML dump default path is `/storage/sql_dump_TIMESTAMP.html` but we can set a different one:

```
return [
    HtmlDumper::class => [
        'path' => storage_path('foo.html'),
    ],
];
```

Also templates and email recipient are customizable, please refer to the \[configuration\]\[link-config\] for further details.

---

This package includes a middleware to easily dump SQL queries in routes or group of routes. The middleware can be registered in `app/Http/Kernel.php`:

```
protected $routeMiddleware = [
    'sql.dump' => \Cerbero\SqlDumper\Http\Middleware\SqlDump::class,
];
```

Then we can add it to routes to run the default dumper:

```
Route::middleware('sql.dump')->get('users', function () {
    return User::all();
});
```

If we want to use a different dumper, we can pass it to the middleware as a parameter:

```
Route::middleware('sql.dump:log')->get('users', function () {
    return User::all();
});
```

The valid parameters are:

- `console`
- `email`
- `html`
- `log`
- `markdown`

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Andrea Sartori](https://twitter.com/cerbero90)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 94.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~123 days

Total

3

Last Release

1949d ago

PHP version history (2 changes)1.0.0PHP ^7.1

1.2.0PHP ^7.1||^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/596523?v=4)[Matteo Picciolini](/maintainers/cerbero)[@cerbero](https://github.com/cerbero)

---

Top Contributors

[![cerbero90](https://avatars.githubusercontent.com/u/5838106?v=4)](https://github.com/cerbero90 "cerbero90 (17 commits)")[![gitetsu](https://avatars.githubusercontent.com/u/44036?v=4)](https://github.com/gitetsu "gitetsu (1 commits)")

---

Tags

laraveldebugsqlquery

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/cerbero-sql-dumper/health.svg)

```
[![Health](https://phpackages.com/badges/cerbero-sql-dumper/health.svg)](https://phpackages.com/packages/cerbero-sql-dumper)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[rennokki/laravel-eloquent-query-cache

Adding cache on your Laravel Eloquent queries' results is now a breeze.

1.1k4.0M14](/packages/rennokki-laravel-eloquent-query-cache)[mehdi-fathi/eloquent-filter

Eloquent Filter adds custom filters automatically to your Eloquent Models in Laravel.It's easy to use and fully dynamic, just with sending the Query Strings to it.

450191.6k1](/packages/mehdi-fathi-eloquent-filter)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
