PHPackages                             dietercoopman/laravel-showsql - 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. dietercoopman/laravel-showsql

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

dietercoopman/laravel-showsql
=============================

A Laravel package to output an sql as given to the database

v1.6(1y ago)21449.9k↓83.4%9[1 issues](https://github.com/dietercoopman/laravel-showsql/issues)[1 PRs](https://github.com/dietercoopman/laravel-showsql/pulls)1MITPHPPHP ^7.4|^8.0|^8.1

Since Sep 30Pushed 1y ago3 watchersCompare

[ Source](https://github.com/dietercoopman/laravel-showsql)[ Packagist](https://packagist.org/packages/dietercoopman/laravel-showsql)[ Docs](https://github.com/dietercoopman/showsql)[ GitHub Sponsors](https://github.com/dietercoopman)[ RSS](/packages/dietercoopman-laravel-showsql/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)Dependencies (2)Versions (14)Used By (1)

[![showsql](https://camo.githubusercontent.com/a4132f74e03b500ab6b7fbfd3b69201ff540ae50a6c7c91630a9cbe69209295e/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c25323073686f7773716c2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d646965746572636f6f706d616e2532466c61726176656c2d73686f7773716c267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d676976696e672b617474656e74696f6e2b746f2b746861742b6f6e652b73716c266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)](https://camo.githubusercontent.com/a4132f74e03b500ab6b7fbfd3b69201ff540ae50a6c7c91630a9cbe69209295e/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c25323073686f7773716c2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d646965746572636f6f706d616e2532466c61726176656c2d73686f7773716c267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d676976696e672b617474656e74696f6e2b746f2b746861742b6f6e652b73716c266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3802b4ac53da40f18ef1dc37bca65a9a874c3f03d9ee15d39a41262f07b3401c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646965746572636f6f706d616e2f6c61726176656c2d73686f7773716c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dietercoopman/laravel-showsql)[![Downloads](https://camo.githubusercontent.com/8dc3dcba0e7694a0789370265b24fe107ace367f98192a5a5ef929730d8cfb61/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646965746572636f6f706d616e2f6c61726176656c2d73686f7773716c2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/8dc3dcba0e7694a0789370265b24fe107ace367f98192a5a5ef929730d8cfb61/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646965746572636f6f706d616e2f6c61726176656c2d73686f7773716c2e7376673f7374796c653d666c61742d737175617265)

Laravel showsql
===============

[](#laravel-showsql)

A Laravel package to output a specific sql to your favourite debugging tool, your browser or your log file.

Use case
--------

[](#use-case)

You often want to draw the attention and look into one single sql while you are developing. You can look up your sql in your favourite debugging tool in the sql tab , but most of the time your sql is not the only sql executed ... So the searching begins. With this package you can add `showSql()` to your QueryBuilder and the single sql will be outputted to the logging of your debug tool.

The supported log output is Laravel Telescope, Laravel Log, Ray, Clockwork, Laravel Debugbar and your browser. By default, showSql will try to log to Ray, Clockwork or the Laravel Debugbar if one of them is installed. If all installed it will be output to all. If you want your own log implementation you can pass a callback to showSql.

If you want to change this behaviour you can publish the config file and change it.

Compatibility
-------------

[](#compatibility)

This package can be installed in Laravel 6,7,8,9,10,11 and 12

Installation
------------

[](#installation)

```
composer require dietercoopman/laravel-showsql --dev
```

Examples
--------

[](#examples)

```
# With the Eloquent Builder

Menu::showSql()->get();

Menu::whereId(1)->showSql()->get();

Menu::whereHas('status')->showSql()->get();

# With the Query Builder

DB::table('menus')->where('id', '=', 10)->showSql()->get();

DB::table('menus')->join('statuses', 'statuses.id', '=', 'menus.status_id')
                 ->showSql()
                 ->get();

# With a callback

$callback = function(string $sql){
  Log::info($sql);
};

DB::table('products')->where('id', '=', 1)->showSql($callback)->get();
```

This is an example log output
-----------------------------

[](#this-is-an-example-log-output)

[![showsql example](example.png)](example.png)

Configuration
-------------

[](#configuration)

You can publish the config file with the following command

```
php artisan vendor:publish --tag=showsql-config
```

Laravel showsql is default configured to output to ray,clockwork and laravel debugbar. If you want to change this you can do it in the published config file.

```
return [
    'to' => [
        'telescope' => false,
        'ray' => true,
        'clockwork' => true,
        'debugbar' => true,
        'log' => false,
        'browser' => false,
    ]
];
```

Why is this not available in the core of Laravel?
-------------------------------------------------

[](#why-is-this-not-available-in-the-core-of-laravel)

I've created a pull request to the framework that has been declined. It adds too much extra logic to the framework itself. The queries as generated in this code are actual not the real statements as passed to your database engines. The real sql never lives in the framework. The query and bindings are passed separately to the database engine and constructed there. So there might be some edge cases. [You can see my pull request here](https://github.com/laravel/framework/pull/39053)

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Dieter Coopman](https://github.com/dietercoopman)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance41

Moderate activity, may be stable

Popularity45

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 92.3% 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 ~103 days

Recently: every ~259 days

Total

13

Last Release

497d ago

PHP version history (3 changes)v1.0PHP ^8.0

v1.1.1PHP ^7.4|^8.0

v1.3.1PHP ^7.4|^8.0|^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a5498402f8114208ae9befe10cb82ea43e33e256ce22c96ff0ec97cb6c87fc5?d=identicon)[dietercoopman](/maintainers/dietercoopman)

---

Top Contributors

[![dietercoopman](https://avatars.githubusercontent.com/u/4672752?v=4)](https://github.com/dietercoopman "dietercoopman (72 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (6 commits)")

---

Tags

laravelsqllaraveldietercoopmanshowsql

### Embed Badge

![Health badge](/badges/dietercoopman-laravel-showsql/health.svg)

```
[![Health](https://phpackages.com/badges/dietercoopman-laravel-showsql/health.svg)](https://phpackages.com/packages/dietercoopman-laravel-showsql)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.9M11.7k](/packages/illuminate-database)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)[lemaur/eloquent-publishing

218.1k1](/packages/lemaur-eloquent-publishing)

PHPackages © 2026

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