ngmy/laravel-query-log-tracker

The Laravel package which log all executed queries.
1,006
Install
composer require ngmy/laravel-query-log-tracker
Latest Version:0.3.0
PHP:^7.3|^8.0
License:MIT
Last Updated:Feb 1, 2023
Links: GitHub  ·  Packagist
Maintainer: ngmy

Laravel Query Log Tracker

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock PHP CI Coverage Status

The Laravel package which log all executed queries.

Demo

Demo

Features

Laravel Query Log Tracker has the following features:

  • Log all executed queries with the following items:
    • SQL with bound parameters
    • Bind parameters
    • Execution time in milliseconds
    • Connection name
  • Disable/Enable query logging at runtime
  • More configurations:
    • Log level
    • Exclude patterns
    • Channels

Requirements

Laravel Query Log Tracker has the following requirements:

  • PHP >= 7.3
  • Laravel >= 6.0

Installation

Execute the Composer require command:

composer require ngmy/laravel-query-log-tracker

This will update your composer.json file and install this package into the vendor directory.

If you don't use package discovery, add the service provider to the providers array in the config/app.php file:

Ngmy\LaravelQueryLogTracker\QueryLogTrackerServiceProvider::class,

If you don't use package discovery, add the alias to the aliases array in the config/app.php file:

'QueryLogTracker' => Ngmy\LaravelQueryLogTracker\QueryLogTrackerFacade::class,

Publishing Configuration

Execute the Artisan vendor:publish command:

php artisan vendor:publish

This will publish the configuration file to the config/ngmy-query-log-tracker.php file.

You can also use the tag to execute the command:

php artisan vendor:publish --tag=ngmy-query-log-tracker

You can also use the service provider to execute the command:

php artisan vendor:publish --provider="Ngmy\LaravelQueryLogTracker\QueryLogTrackerServiceProvider"

Usage

Log Queries

Execute queries with Laravel. That's all.

Disable Log

There are two ways to disable log.

QueryLogTracker::beginDisable();
// Execute queries for which you want to disable log
QueryLogTracker::endDisable();
QueryLogTracker::disable(function () {
    // Execute queries for which you want to disable log
});

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

634,760,849 9,707
laravel/framework

The Laravel Framework.

584,532,650 34,931
laravel/tinker

Powerful REPL for the Laravel framework.

493,838,477 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

408,553,772 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

391,429,217 4,660