Skip to content

Commit d18e95b

Browse files
authored
Update README.md
1 parent de0233f commit d18e95b

File tree

1 file changed

+2
-89
lines changed

1 file changed

+2
-89
lines changed

README.md

+2-89
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ The Laravel N+1 query detector helps you to increase your application's performa
99

1010
![Example alert](https://beyondco.de/github/n+1/alert.png)
1111

12-
> If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming [PHP Package Development](https://phppackagedevelopment.com) video course.
13-
1412

1513
## Installation
1614

@@ -22,95 +20,10 @@ composer require beyondcode/laravel-query-detector --dev
2220

2321
The package will automatically register itself.
2422

25-
## Usage
26-
27-
If you run your application in the `debug` mode, the query monitor will be automatically active. So there is nothing you have to do.
28-
29-
By default, this package will display an `alert()` message to notify you about an N+1 query found in the current request.
30-
31-
If you rather want this information to be written to your `laravel.log` file, written to your browser's console log as a warning or listed in a new tab for the [Laravel Debugbar (barryvdh/laravel-debugbar)](https://github.com/barryvdh/laravel-debugbar), you can publish the configuration and change the output behaviour (see example below).
32-
33-
You can publish the package's configuration using this command:
34-
35-
```bash
36-
php artisan vendor:publish --provider="BeyondCode\QueryDetector\QueryDetectorServiceProvider"
37-
```
38-
39-
This will add the `querydetector.php` file in your config directory with the following contents:
40-
41-
```php
42-
<?php
43-
44-
return [
45-
/*
46-
* Enable or disable the query detection.
47-
* If this is set to "null", the app.debug config value will be used.
48-
*/
49-
'enabled' => env('QUERY_DETECTOR_ENABLED', null),
50-
51-
/*
52-
* Threshold level for the N+1 query detection. If a relation query will be
53-
* executed more then this amount, the detector will notify you about it.
54-
*/
55-
'threshold' => (int) env('QUERY_DETECTOR_THRESHOLD', 1),
56-
57-
/*
58-
* Here you can whitelist model relations.
59-
*
60-
* Right now, you need to define the model relation both as the class name and the attribute name on the model.
61-
* So if an "Author" model would have a "posts" relation that points to a "Post" class, you need to add both
62-
* the "posts" attribute and the "Post::class", since the relation can get resolved in multiple ways.
63-
*/
64-
'except' => [
65-
//Author::class => [
66-
// Post::class,
67-
// 'posts',
68-
//]
69-
],
70-
71-
/*
72-
* Define the output format that you want to use. Multiple classes are supported.
73-
* Available options are:
74-
*
75-
* Alert:
76-
* Displays an alert on the website
77-
* \BeyondCode\QueryDetector\Outputs\Alert::class
78-
*
79-
* Console:
80-
* Writes the N+1 queries into your browsers console log
81-
* \BeyondCode\QueryDetector\Outputs\Console::class
82-
*
83-
* Clockwork: (make sure you have the itsgoingd/clockwork package installed)
84-
* Writes the N+1 queries warnings to Clockwork log
85-
* \BeyondCode\QueryDetector\Outputs\Clockwork::class
86-
*
87-
* Debugbar: (make sure you have the barryvdh/laravel-debugbar package installed)
88-
* Writes the N+1 queries into a custom messages collector of Debugbar
89-
* \BeyondCode\QueryDetector\Outputs\Debugbar::class
90-
*
91-
* JSON:
92-
* Writes the N+1 queries into the response body of your JSON responses
93-
* \BeyondCode\QueryDetector\Outputs\Json::class
94-
*
95-
* Log:
96-
* Writes the N+1 queries into the Laravel.log file
97-
* \BeyondCode\QueryDetector\Outputs\Log::class
98-
*/
99-
'output' => [
100-
\BeyondCode\QueryDetector\Outputs\Log::class,
101-
\BeyondCode\QueryDetector\Outputs\Alert::class,
102-
]
103-
104-
];
105-
```
106-
107-
If you use **Lumen**, you need to copy the config file manually and register the Lumen Service Provider in `bootstrap/app.php` file
23+
## Documentation
10824

109-
```php
110-
$app->register(\BeyondCode\QueryDetector\LumenQueryDetectorServiceProvider::class);
111-
```
25+
You can find the documentation on our [website](http://beyondco.de/docs/laravel-query-detector).
11226

113-
If you need additional logic to run when the package detects unoptimized queries, you can listen to the `\BeyondCode\QueryDetector\Events\QueryDetected` event and write a listener to run your own handler. (e.g. send warning to Sentry/Bugsnag, send Slack notification, etc.)
11427

11528
### Testing
11629

0 commit comments

Comments
 (0)