2017 © Pedro PelĂĄez
 

library laravel-sql-logger

Log SQL queries in Laravel/Lumen framework

image

mnabialek/laravel-sql-logger

Log SQL queries in Laravel/Lumen framework

  • Tuesday, July 17, 2018
  • by mnabialek
  • Repository
  • 8 Watchers
  • 51 Stars
  • 27,815 Installations
  • PHP
  • 4 Dependents
  • 0 Suggesters
  • 8 Forks
  • 1 Open issues
  • 14 Versions
  • 26 % Grown

The README.md

Laravel SQL Logger

Packagist Support via Paypal Build Status Coverage Status Scrutinizer Code Quality, (*1)

This module allows you to log SQL queries (and slow SQL queries) to log file in Laravel/Lumen framework. It's useful mainly when developing your application to verify whether your queries are valid and to make sure your application doesn't run too many or too slow database queries., (*2)

Support

Using this package is free of charge, however to keep it up-to-date and add new features small money support is appreciated. Suggested amount is 5$ per project where you use this package but any amount will help further development of this package. Support via Paypal (you are free to change amount on Paypal page), (*3)

Installation

  1. Run, (*4)

    composer require mnabialek/laravel-sql-logger --dev
    

    in console to install this module (Notice --dev flag - it's recommended to use this package only for development)., (*5)

  2. If you use Laravel < 5.5 open config/app.php and in providers section add:, (*6)

    Mnabialek\LaravelSqlLogger\Providers\ServiceProvider::class,
    

    Laravel 5.5 uses Package Auto-Discovery and it will automatically load this service provider so you don't need to add anything into above file., (*7)

    If you are using Lumen open bootstrap/app.php and add:, (*8)

    $app->register(Mnabialek\LaravelSqlLogger\Providers\ServiceProvider::class);
    
  3. If you use Laravel < 5.5 run:, (*9)

    php artisan vendor:publish --provider="Mnabialek\LaravelSqlLogger\Providers\ServiceProvider"
    

    in your console to publish default configuration files., (*10)

    If you are using Laravel 5.5 run:, (*11)

    php artisan vendor:publish
    

    and choose the number matching "Mnabialek\LaravelSqlLogger\Providers\ServiceProvider" provider., (*12)

    By default you should not edit published file because all the settings are loaded from .env file by default., (*13)

    For Lumen you should skip this step., (*14)

  4. In your .env file add the following entries:, (*15)

    SQL_LOGGER_DIRECTORY="logs/sql"
    SQL_LOGGER_USE_SECONDS=false
    SQL_LOGGER_CONSOLE_SUFFIX=
    SQL_LOGGER_LOG_EXTENSION=".sql"
    SQL_LOGGER_ALL_QUERIES_ENABLED=true
    SQL_LOGGER_ALL_QUERIES_OVERRIDE=false
    SQL_LOGGER_ALL_QUERIES_PATTERN="#.*#i"
    SQL_LOGGER_ALL_QUERIES_FILE_NAME="[Y-m-d]-log"
    SQL_LOGGER_SLOW_QUERIES_ENABLED=true
    SQL_LOGGER_SLOW_QUERIES_MIN_EXEC_TIME=100
    SQL_LOGGER_SLOW_QUERIES_PATTERN="#.*#i"
    SQL_LOGGER_SLOW_QUERIES_FILE_NAME="[Y-m-d]-slow-log"
    SQL_LOGGER_FORMAT_NEW_LINES_TO_SPACES=false
    SQL_LOGGER_FORMAT_ENTRY_FORMAT="/* [origin]\\n   Query [query_nr] - [datetime] [[query_time]] */\\n[query]\\n[separator]\\n"
    

    and adjust values to your needs. You can skip variables for which you want to use default values., (*16)

    If you have also .env.sample it's also recommended to add those entries also in .env.sample file just to make sure everyone know about those env variables. Be aware that SQL_LOGGER_DIRECTORY is directory inside storage directory. If you want you can change it editing config/sql_logger.php file., (*17)

    To find out more about those setting please take a look at Configuration file, (*18)

  5. Make sure directory specified in .env file exists in storage path and you have valid file permissions to create and modify files in this directory (If it does not exist this package will automatically create it when needed but it's recommended to create it manually with valid file permissions), (*19)

  6. Make sure on live server you will set logging SQL queries to false in your .env file. This package is recommended to be used only for development to not impact production application performance., (*20)

Upgrading from 1.*

When upgrading from 1.* version you should remove current sql_logger.php config file and replace this with new one (see installation step). You should also use new variables in .env file (old won't be used)., (*21)

Authors

Author of this awesome package is Marcin NabiaƂek and Contributors, (*22)

Changes

All changes are listed in Changelog, (*23)

License

This package is licenced under the MIT license however Support is more than welcome., (*24)

The Versions

17/07 2018

dev-master

9999999-dev

Log SQL queries in Laravel/Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcin NabiaƂek

laravel sql logger log lumen sql logger log sql queries

17/07 2018
13/06 2018
12/05 2018
23/03 2018

v2.0.1

2.0.1.0

Log SQL queries in Laravel/Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcin NabiaƂek

laravel sql logger log lumen sql logger log sql queries

11/02 2018

v2.0

2.0.0.0

Log SQL queries in Laravel/Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcin NabiaƂek

laravel sql logger log lumen sql logger log sql queries

18/01 2018

1.0.x-dev

1.0.9999999.9999999-dev

Log SQL queries in Laravel/Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcin NabiaƂek

laravel sql logger log lumen sql logger log sql queries

18/01 2018

v1.1.4

1.1.4.0

Log SQL queries in Laravel/Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcin NabiaƂek

laravel sql logger log lumen sql logger log sql queries

03/09 2017

v1.1.3

1.1.3.0

Log SQL queries in Laravel/Lumen framework

  Sources   Download

MIT

The Requires

 

The Development Requires

by Marcin NabiaƂek

laravel sql logger log lumen sql logger log sql queries

24/01 2017

v1.1.2

1.1.2.0

Log SQL queries in Laravel/Lumen framework

  Sources   Download

MIT

The Requires

 

by Marcin NabiaƂek

laravel sql logger log lumen

10/06 2016

v1.1.1

1.1.1.0

Log SQL queries in Laravel/Lumen framework

  Sources   Download

MIT

The Requires

 

by Marcin NabiaƂek

laravel sql logger log lumen

09/06 2016

v1.1

1.1.0.0

Log SQL queries in Laravel/Lumen framework

  Sources   Download

MIT

The Requires

 

by Marcin NabiaƂek

laravel sql logger log lumen

09/06 2016

dev-develop

dev-develop

Log SQL queries in Laravel/Lumen framework

  Sources   Download

MIT

The Requires

 

by Marcin NabiaƂek

laravel sql logger log lumen

16/02 2016

v1.0

1.0.0.0

Log SQL queries in Laravel/Lumen framework

  Sources   Download

MIT

The Requires

 

by Marcin NabiaƂek

laravel sql logger log lumen