sakiot/laravel-sql-spy

v0.0.1-alpha.3 2022-08-04 02:40 UTC

This package is auto-updated.

Last update: 2024-05-11 12:13:51 UTC


README

StyleCI

SQL query aggregation tool for refactoring

(!)This library is under development.

Laravel Sql Spy is a tool for inspecting the SQL queries issued by your application built with Laravel. To find duplicate and redundant queries that are the main source of load, it's not enough to just get a list of query submission logs.

Laravel Sql Spy groups issued queries and supports refactoring efficiently.

Requirements

  • PHP >= 8.x
  • Laravel >= 8.x

Installation

Step 1: Install package

Use Composer command to add the package.

composer require sakiot/laravel-sql-spy

Step 2: Register Service Provider

Register the Service Provider in your config file.

// config/app.php

'providers' => [
    // Application Service Providers...
    // ...

    // Other Service Providers...
    LaravelSqlSpy\LaravelSqlSpyServiceProvider::class, // add
],

Usage

Turn on debug mode in your environment file.

// .env

APP_DEBUG=true

Then you will see the Sql Spy button on the top right of the page. By clicking this button, you can download the csv file.

Currently, I'm using sessions to hold data. So if you open multiple tabs in your browser, the data of the last opened page will be retrieved. The "page where the button was clicked" is irrelevant. You will always get the "last opened page" information!