You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This module allows you to log SQL queries (and slow SQL queries) to log file in Laravel framework. It's useful mainly
7
+
This module allows you to log SQL queries to log file in Laravel framework. It's useful mainly
9
8
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.
10
9
10
+
It reports a lot of metadata like total query count, total execution time, origin (request URL/console command), authenticated user, app environment, client browser agent / IP / hostname. You're also able to limit queries by a regex pattern, so you could e.g. only log
11
+
11
12
## Installation
12
13
13
14
1. Run
@@ -26,7 +27,7 @@ when developing your application to verify whether your queries are valid and to
26
27
27
28
By default you should not edit published file because all the settings are loaded from `.env` file by default.
28
29
29
-
3. In your .env file add the following entries:
30
+
3. In your `.env` file add the following entries:
30
31
31
32
```ini
32
33
SQL_REPORTER_DIRECTORY="logs/sql"
@@ -42,15 +43,21 @@ when developing your application to verify whether your queries are valid and to
and adjust values to your needs. You can skip variables for which you want to use default values.
46
+
and adjust values to your needs. You can skip variables for which you want to use default values.
47
+
48
+
To only log DML / modifying queries like `INSERT`, `UPDATE`, `DELETE`, I recommend to use:
49
+
50
+
```ini
51
+
SQL_REPORTER_QUERIES_PATTERN="/^(?!SELECT).*$/i"
52
+
```
46
53
47
-
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_REPORTER_DIRECTORY` is directory inside storage directory. If you want you can change it editing `config/sql-reporter.php` file.
54
+
If you have also `.env.example` it's recommended to add those entries also in `.env.example` file just to make sure everyone knows about those env variables. Be aware that `SQL_REPORTER_DIRECTORY` is directory inside storage directory.
48
55
49
56
To find out more about those setting please take a look at [Configuration file](config/sql-reporter.php)
50
57
51
58
4. 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)
52
59
53
-
5. Make sure on live server you will set logging SQL queries to falsein your `.env` file. This package is recommended to be used only for development to not impact production application performance.
60
+
5. Make sure on live server you will set logging SQL queries to falsein your `.env` file: `SQL_REPORTER_QUERIES_ENABLED=false`. This package is recommended to be used only for development to not impact production application performance.
0 commit comments