PHPackages                             toanld/laravel-debug-to-sql - 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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. toanld/laravel-debug-to-sql

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

toanld/laravel-debug-to-sql
===========================

Help you find out which file the query is in in the code.

v1.1.9(2y ago)03511PHP

Since Aug 31Pushed 2y ago1 watchersCompare

[ Source](https://github.com/toanld/laravel-debug-to-sql)[ Packagist](https://packagist.org/packages/toanld/laravel-debug-to-sql)[ RSS](/packages/toanld-laravel-debug-to-sql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (11)Used By (1)

Introducing Laravel Debug To SQL
================================

[](#introducing-laravel-debug-to-sql)

The `toanld/laravel-debug-to-sql` package for Laravel is designed to help developers identify the origin of slow or erroneous queries in their Laravel applications. By displaying file information in the query output, it allows developers to pinpoint the exact location in the code where a query is being executed. This is particularly useful when analyzing MySQL slow query logs, as it provides a clear link between the log entry and the corresponding code.

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

[](#installation)

To install the package, use Composer:

bash

Copy code

`composer require toanld/laravel-debug-to-sql`

Usage
-----

[](#usage)

Using the `DebugToSQL` trait in your Eloquent models will enable the package's functionality. Here’s a simple example to get you started:

```
composer require toanld/laravel-debug-to-sql
```

### Syntax

[](#syntax)

```
namespace App;

use Illuminate\Database\Eloquent\Model;
use Toanld\DebugToSql\DebugToSQL;

class Test extends Model
{
    use DebugToSQL;
}
```

How It Works
------------

[](#how-it-works)

Once the `DebugToSQL` trait is added to a model, every time a query is executed using that model, the file and line number from which the query originated will be included in the query output. This information is invaluable for debugging slow queries or tracking down the source of query errors.

### Benefits

[](#benefits)

- **Enhanced Debugging**: Quickly locate the file and line number in your codebase where a problematic query is executed.
- **Performance Monitoring**: Identify slow queries and their origins in your code, making it easier to optimize performance.
- **Error Tracking**: Trace query errors back to the exact line in your code, simplifying the debugging process.

### Practical Example

[](#practical-example)

Imagine you have a Laravel application and you notice some slow queries in your MySQL slow query log. By using this package, the log entries will now include information about the file and line number where each query is called. This makes it much easier to find and optimize the specific parts of your code responsible for the slow queries.

### Getting Started

[](#getting-started)

1. **Install the Package**: Use Composer to add the package to your Laravel project.
2. **Add the Trait**: Include the `DebugToSQL` trait in your Eloquent models.
3. **Monitor Queries**: Run your application and monitor the queries. The output will now include detailed file information for each query.

### Conclusion

[](#conclusion)

The `toanld/laravel-debug-to-sql` package is a powerful tool for any Laravel developer looking to improve their application's performance and debugging capabilities. By providing clear and actionable insights into where queries are executed in your code, it makes the process of identifying and resolving issues much more efficient.

For more details and to download the package, visit the [Packagist page](https://packagist.org/packages/toanld/laravel-debug-to-sql).

---

Feel free to reach out if you have any questions or need further assistance with using this package. Happy coding!

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~48 days

Recently: every ~39 days

Total

10

Last Release

920d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b884bdad7cead7cd70b807b4c4f3453d6eee6f4e7e8326b42a799553fb63eb9c?d=identicon)[toanld1905](/maintainers/toanld1905)

---

Top Contributors

[![toanld](https://avatars.githubusercontent.com/u/33773069?v=4)](https://github.com/toanld "toanld (6 commits)")

### Embed Badge

![Health badge](/badges/toanld-laravel-debug-to-sql/health.svg)

```
[![Health](https://phpackages.com/badges/toanld-laravel-debug-to-sql/health.svg)](https://phpackages.com/packages/toanld-laravel-debug-to-sql)
```

###  Alternatives

[symfony/stopwatch

Provides a way to profile code

2.8k387.2M918](/packages/symfony-stopwatch)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[spatie/ignition

A beautiful error page for PHP applications.

510147.6M69](/packages/spatie-ignition)[jokkedk/webgrind

Webgrind is a Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.

3.3k193.0k](/packages/jokkedk-webgrind)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[soloterm/dumps

A Laravel command to intercept dumps from your Laravel application.

125285.7k3](/packages/soloterm-dumps)

PHPackages © 2026

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