PHPackages                             rifat-simoom/query-logger - 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. rifat-simoom/query-logger

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

rifat-simoom/query-logger
=========================

A framework-agnostic query logger for PHP projects using PDO.

v1.0.6(1y ago)2102MITPHPPHP &gt;=7.4

Since Apr 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/rifat-simoom/query-logger)[ Packagist](https://packagist.org/packages/rifat-simoom/query-logger)[ RSS](/packages/rifat-simoom-query-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (9)Used By (0)

Query Logger
============

[](#query-logger)

[![Packagist Version](https://camo.githubusercontent.com/68ebd0414cbeffb4061785891f0dcc1b397d8d23533237d140234945951a6d66/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72696661742d73696d6f6f6d2f71756572792d6c6f67676572)](https://camo.githubusercontent.com/68ebd0414cbeffb4061785891f0dcc1b397d8d23533237d140234945951a6d66/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72696661742d73696d6f6f6d2f71756572792d6c6f67676572)[![License](https://camo.githubusercontent.com/0a408d4db3b9ae9f5f426312e2ffaec9fedd7b78f2dd15fcbf5baa063cc3798c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f72696661742d73696d6f6f6d2f71756572792d6c6f67676572)](https://camo.githubusercontent.com/0a408d4db3b9ae9f5f426312e2ffaec9fedd7b78f2dd15fcbf5baa063cc3798c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f72696661742d73696d6f6f6d2f71756572792d6c6f67676572)[![Downloads](https://camo.githubusercontent.com/86d5f1b4eba7fc74f13583fc9f2aeb4b3d070dde08603df207976ebeeffc7e0e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72696661742d73696d6f6f6d2f71756572792d6c6f67676572)](https://camo.githubusercontent.com/86d5f1b4eba7fc74f13583fc9f2aeb4b3d070dde08603df207976ebeeffc7e0e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72696661742d73696d6f6f6d2f71756572792d6c6f67676572)

Query Logger is a lightweight PHP library for logging SQL queries executed via PDO. It is framework-agnostic but can be seamlessly integrated into Laravel.

✨ Features
----------

[](#-features)

- Logs all SQL queries with execution time
- Includes a stack trace for better debugging
- Works with any PHP project using PDO
- Simple and efficient implementation

📦 Installation
--------------

[](#-installation)

You can install the package via Composer:

```
composer require rifat-simoom/query-logger
```

🚀 Usage
-------

[](#-usage)

### **Standalone PHP Usage**

[](#standalone-php-usage)

```
require 'vendor/autoload.php';

use RifatSimoom\QueryLogger;

$pdo = new PDO('mysql:host=localhost;dbname=test', 'root', '');
$logger = new QueryLogger($pdo, __DIR__ . '/logs/query.log');
$logger->startLogging();
```

### **Using in Laravel**

[](#using-in-laravel)

For Laravel applications, you can integrate it as follows:

```
use RifatSimoom\QueryLogger;
use Illuminate\Support\Facades\DB;

$logger = new QueryLogger(DB::connection()->getPdo(), storage_path("/logs/get-token-query.log"));
$logger->startLogging();
```

⚙️ Configuration
----------------

[](#️-configuration)

By default, the logger saves queries in the specified log file. You can customize:

- **Log file location**
- **Formatting of logged queries**
- **Filtering specific queries**

📄 Example Log Output
--------------------

[](#-example-log-output)

```
[2025-04-02 17:14:01]
1. SELECT * FROM users WHERE email = 'test@example.com'
Time: 0.00235s
Trace:
/var/www/html/repos/query-logger/src/QueryLogger.php:46
/var/www/html/repos/query-logger/src/LoggedStatement.php:37
/var/www/html/repos/query-logger/tests/QueryLoggerTest.php:34```

```

🛠️ Contributing
---------------

[](#️-contributing)

Contributions are welcome! Please fork the repository and submit a pull request.

📜 License
---------

[](#-license)

This project is open-sourced under the MIT License.

📬 Contact
---------

[](#-contact)

For issues, please open a GitHub issue or reach out to .

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance49

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity42

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 ~0 days

Total

7

Last Release

402d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/341cbc3126111fb05110765503a9ed4551a4db059defce0275612f458e97a182?d=identicon)[rifat-simoom](/maintainers/rifat-simoom)

---

Top Contributors

[![rifat-simoom](https://avatars.githubusercontent.com/u/5784185?v=4)](https://github.com/rifat-simoom "rifat-simoom (10 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rifat-simoom-query-logger/health.svg)

```
[![Health](https://phpackages.com/badges/rifat-simoom-query-logger/health.svg)](https://phpackages.com/packages/rifat-simoom-query-logger)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

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

MongoDB driver library

1.6k64.0M542](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M209](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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