|
4 | 4 | * Laravel 5.5+
|
5 | 5 |
|
6 | 6 | ## Installation
|
7 |
| -Install the package |
| 7 | +You can install the package via composer: |
8 | 8 | ```bash
|
9 | 9 | composer require ilzrv/laravel-slow-query-detector
|
10 | 10 | ```
|
11 | 11 |
|
12 |
| -Publish the configuration file |
| 12 | +## Configuration |
| 13 | +By default, the package is already configured and enabled, but you can change the settings if necessary. |
| 14 | +To publish the configuration file, run: |
13 | 15 | ```bash
|
14 | 16 | php artisan vendor:publish --provider="Ilzrv\LaravelSlowQueryDetector\ServiceProvider"
|
15 | 17 | ```
|
| 18 | + |
| 19 | +### `SQD_ENABLED` |
| 20 | +Determines whether query listening is enabled. |
| 21 | + |
| 22 | +### `SQD_CODE_MAX_QUERIES` |
| 23 | +Maximum number of queries when processing the controller method. |
| 24 | +If your method executes more queries than this value the notification will be received. |
| 25 | + |
| 26 | +### `SQD_CODE_MAX_TIME` |
| 27 | +Maximum execution time of the controller method (in ms). |
| 28 | +If your method takes longer than this value to complete the notification will be received. |
| 29 | + |
| 30 | +### `SQD_QUERY_BINDINGS` |
| 31 | +Queries with bindings. |
| 32 | +If true then bindings will be applied to queries in notification. |
| 33 | +Example (if true): `select * from users where name = John` instead of `select * from users where name = ?` |
| 34 | + |
| 35 | +### `SQD_QUERY_MAX_TIME` |
| 36 | +Maximum execution time for each query in DB (in ms). |
| 37 | +If at least one query exceeds this value |
| 38 | +you will receive a notification. |
| 39 | + |
| 40 | +## Example logs output: |
| 41 | +```bash |
| 42 | +[2020-04-12 06:59:21] production.CRITICAL: Array |
| 43 | +( |
| 44 | + [SQD] => Array |
| 45 | + ( |
| 46 | + [Execution Time] => 60 ms. |
| 47 | + [Queries Count] => 2 |
| 48 | + [Heavy Queries Count] => 2 |
| 49 | + [Full URL] => https://example.org/?name=John |
| 50 | + [Action] => App\Http\Controllers\HomeController@index |
| 51 | + [Heaviest Query] => Array |
| 52 | + ( |
| 53 | + [Query] => select * from `users` where `name` = John |
| 54 | + [Time] => 50.67 ms. |
| 55 | + ) |
| 56 | + |
| 57 | + ) |
| 58 | +) |
| 59 | +``` |
0 commit comments