From d1061d81d2d51e5f4b7c00f279b0e9ab81533cf4 Mon Sep 17 00:00:00 2001 From: Adam Kaczocha Date: Thu, 16 May 2024 13:22:30 +1000 Subject: [PATCH 1/3] Initial Commit With Updates --- .editorconfig | 30 +++--- .gitattributes | 22 ++--- .gitignore | 3 +- .scrutinizer.yml | 52 +++++----- .styleci.yml | 8 +- .travis.yml | 60 ------------ CHANGELOG.md | 14 +-- CONTRIBUTING.md | 110 +++++++++++----------- LICENSE.md | 42 ++++----- README.md | 10 +- composer.json | 34 ++++--- config/config.php | 16 ++-- docs/_index.md | 4 +- docs/installation.md | 4 +- docs/usage.md | 22 ++--- phpunit.xml.dist | 19 +--- src/Events/QueryDetected.php | 2 +- src/LumenQueryDetectorServiceProvider.php | 2 +- src/Outputs/Alert.php | 2 +- src/Outputs/Clockwork.php | 2 +- src/Outputs/Console.php | 2 +- src/Outputs/Debugbar.php | 4 +- src/Outputs/Json.php | 4 +- src/Outputs/Log.php | 2 +- src/Outputs/Output.php | 2 +- src/QueryDetector.php | 6 +- src/QueryDetectorMiddleware.php | 4 +- src/QueryDetectorServiceProvider.php | 2 +- tests/Factories/ModelFactory.php | 12 +-- tests/Models/Author.php | 2 +- tests/Models/Comment.php | 2 +- tests/Models/Post.php | 2 +- tests/Models/Profile.php | 2 +- tests/Models/User.php | 2 +- tests/QueryDetectorTest.php | 12 +-- tests/Seeder/TestSeeder.php | 12 +-- tests/TestCase.php | 6 +- 37 files changed, 232 insertions(+), 304 deletions(-) delete mode 100644 .travis.yml diff --git a/.editorconfig b/.editorconfig index cd8eb86..293961c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,15 +1,15 @@ -; This file is for unifying the coding style for different editors and IDEs. -; More information at http://editorconfig.org - -root = true - -[*] -charset = utf-8 -indent_size = 4 -indent_style = space -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -[*.md] -trim_trailing_whitespace = false +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes index bb6265e..295d989 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,11 +1,11 @@ -# Path-based git attributes -# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html - -# Ignore all test and documentation with "export-ignore". -/.gitattributes export-ignore -/.gitignore export-ignore -/.travis.yml export-ignore -/phpunit.xml.dist export-ignore -/.scrutinizer.yml export-ignore -/tests export-ignore -/.editorconfig export-ignore +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all test and documentation with "export-ignore". +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/phpunit.xml.dist export-ignore +/.scrutinizer.yml export-ignore +/tests export-ignore +/.editorconfig export-ignore diff --git a/.gitignore b/.gitignore index 28367bb..bce2592 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ composer.lock vendor coverage .idea -nbproject \ No newline at end of file +nbproject +.vscode diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 7f6f12d..d5b1b10 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,26 +1,26 @@ -filter: - excluded_paths: [tests/*] - -build: - nodes: - analysis: - tests: - override: - - php-scrutinizer-run - -checks: - php: - remove_extra_empty_lines: true - remove_php_closing_tag: true - remove_trailing_whitespace: true - fix_use_statements: - remove_unused: true - preserve_multiple: false - preserve_blanklines: true - order_alphabetically: true - fix_php_opening_tag: true - fix_linefeed: true - fix_line_ending: true - fix_identation_4spaces: true - fix_doc_comments: true - +filter: + excluded_paths: [tests/*] + +build: + nodes: + analysis: + tests: + override: + - php-scrutinizer-run + +checks: + php: + remove_extra_empty_lines: true + remove_php_closing_tag: true + remove_trailing_whitespace: true + fix_use_statements: + remove_unused: true + preserve_multiple: false + preserve_blanklines: true + order_alphabetically: true + fix_php_opening_tag: true + fix_linefeed: true + fix_line_ending: true + fix_identation_4spaces: true + fix_doc_comments: true + diff --git a/.styleci.yml b/.styleci.yml index f4d3cbc..fa0b7bc 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,4 +1,4 @@ -preset: laravel - -disabled: - - single_class_element_per_statement +preset: laravel + +disabled: + - single_class_element_per_statement diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2eb3583..0000000 --- a/.travis.yml +++ /dev/null @@ -1,60 +0,0 @@ -language: php - -php: - - 7.1 - - 7.2 - - 7.3 - - 7.4 - - 8.0 - -env: - - LARAVEL="^5.5" COMPOSER_FLAGS="--prefer-lowest" - - LARAVEL="^5.5" COMPOSER_FLAGS="" - - LARAVEL="^6.0" COMPOSER_FLAGS="--prefer-lowest" - - LARAVEL="^6.0" COMPOSER_FLAGS="" - - LARAVEL="^7.0" COMPOSER_FLAGS="--prefer-lowest" - - LARAVEL="^7.0" COMPOSER_FLAGS="" - - LARAVEL="^8.0" COMPOSER_FLAGS="--prefer-lowest" - - LARAVEL="^8.0" COMPOSER_FLAGS="" - -matrix: - exclude: - - php: 7.1 - env: LARAVEL="^6.0" COMPOSER_FLAGS="--prefer-lowest" - - php: 7.1 - env: LARAVEL="^6.0" COMPOSER_FLAGS="" - - php: 7.1 - env: LARAVEL="^7.0" COMPOSER_FLAGS="--prefer-lowest" - - php: 7.1 - env: LARAVEL="^7.0" COMPOSER_FLAGS="" - - php: 7.1 - env: LARAVEL="^8.0" COMPOSER_FLAGS="--prefer-lowest" - - php: 7.1 - env: LARAVEL="^8.0" COMPOSER_FLAGS="" - allow_failures: - - php: 7.4 - env: LARAVEL="^5.5" COMPOSER_FLAGS="--prefer-lowest" - - php: 7.4 - env: LARAVEL="^6.0" COMPOSER_FLAGS="--prefer-lowest" - - php: 8.0 - env: LARAVEL="^5.5" COMPOSER_FLAGS="--prefer-lowest" - - php: 8.0 - env: LARAVEL="^6.0" COMPOSER_FLAGS="--prefer-lowest" - - -cache: - directories: - - $HOME/.composer/cache/files - -before_install: - - echo "memory_limit=2G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - -install: - - travis_retry composer require laravel/framework:${LARAVEL} --no-interaction --prefer-dist - - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist - -script: - - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - -after_script: - - php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover diff --git a/CHANGELOG.md b/CHANGELOG.md index 7156b62..569e2bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ -# Changelog - -All notable changes to `laravel-query-detector` will be documented in this file - -## 1.0.0 - 201X-XX-XX - -- initial release +# Changelog + +All notable changes to `laravel-query-detector` will be documented in this file + +## 1.0.0 - 201X-XX-XX + +- initial release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b4ae1c4..11a9e31 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,55 +1,55 @@ -# Contributing - -Contributions are **welcome** and will be fully **credited**. - -Please read and understand the contribution guide before creating an issue or pull request. - -## Etiquette - -This project is open source, and as such, the maintainers give their free time to build and maintain the source code -held within. They make the code freely available in the hope that it will be of use to other developers. It would be -extremely unfair for them to suffer abuse or anger for their hard work. - -Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the -world that developers are civilized and selfless people. - -It's the duty of the maintainer to ensure that all submissions to the project are of sufficient -quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. - -## Viability - -When requesting or submitting new features, first consider whether it might be useful to others. Open -source projects are used by many developers, who may have entirely different needs to your own. Think about -whether or not your feature is likely to be used by other users of the project. - -## Procedure - -Before filing an issue: - -- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. -- Check to make sure your feature suggestion isn't already present within the project. -- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. -- Check the pull requests tab to ensure that the feature isn't already in progress. - -Before submitting a pull request: - -- Check the codebase to ensure that your feature doesn't already exist. -- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. - -## Requirements - -If the project maintainer has any additional requirements, you will find them listed here. - -- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). - -- **Add tests!** - Your patch won't be accepted if it doesn't have tests. - -- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. - -- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. - -- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. - -- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. - -**Happy coding**! +# Contributing + +Contributions are **welcome** and will be fully **credited**. + +Please read and understand the contribution guide before creating an issue or pull request. + +## Etiquette + +This project is open source, and as such, the maintainers give their free time to build and maintain the source code +held within. They make the code freely available in the hope that it will be of use to other developers. It would be +extremely unfair for them to suffer abuse or anger for their hard work. + +Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the +world that developers are civilized and selfless people. + +It's the duty of the maintainer to ensure that all submissions to the project are of sufficient +quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used. + +## Viability + +When requesting or submitting new features, first consider whether it might be useful to others. Open +source projects are used by many developers, who may have entirely different needs to your own. Think about +whether or not your feature is likely to be used by other users of the project. + +## Procedure + +Before filing an issue: + +- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident. +- Check to make sure your feature suggestion isn't already present within the project. +- Check the pull requests tab to ensure that the bug doesn't have a fix in progress. +- Check the pull requests tab to ensure that the feature isn't already in progress. + +Before submitting a pull request: + +- Check the codebase to ensure that your feature doesn't already exist. +- Check the pull requests to ensure that another person hasn't already submitted the feature or fix. + +## Requirements + +If the project maintainer has any additional requirements, you will find them listed here. + +- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer). + +- **Add tests!** - Your patch won't be accepted if it doesn't have tests. + +- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. + +- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option. + +- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests. + +- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. + +**Happy coding**! diff --git a/LICENSE.md b/LICENSE.md index 08a23cf..f3e2bf4 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) Beyond Code GmbH - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +The MIT License (MIT) + +Copyright (c) Beyond Code GmbH + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index e356d24..e33d9ad 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Laravel N+1 Query Detector -[![Latest Version on Packagist](https://img.shields.io/packagist/v/beyondcode/laravel-query-detector.svg?style=flat-square)](https://packagist.org/packages/beyondcode/laravel-query-detector) -[![Build Status](https://img.shields.io/travis/beyondcode/laravel-query-detector/master.svg?style=flat-square)](https://travis-ci.org/beyondcode/laravel-query-detector) -[![Quality Score](https://img.shields.io/scrutinizer/g/beyondcode/laravel-query-detector.svg?style=flat-square)](https://scrutinizer-ci.com/g/beyondcode/laravel-query-detector) -[![Total Downloads](https://img.shields.io/packagist/dt/beyondcode/laravel-query-detector.svg?style=flat-square)](https://packagist.org/packages/beyondcode/laravel-query-detector) +[![Latest Version on Packagist](https://img.shields.io/packagist/v/Mrkatz/laravel-query-detector.svg?style=flat-square)](https://packagist.org/packages/Mrkatz/laravel-query-detector) +[![Build Status](https://img.shields.io/travis/Mrkatz/laravel-query-detector/master.svg?style=flat-square)](https://travis-ci.org/Mrkatz/laravel-query-detector) +[![Quality Score](https://img.shields.io/scrutinizer/g/Mrkatz/laravel-query-detector.svg?style=flat-square)](https://scrutinizer-ci.com/g/Mrkatz/laravel-query-detector) +[![Total Downloads](https://img.shields.io/packagist/dt/Mrkatz/laravel-query-detector.svg?style=flat-square)](https://packagist.org/packages/Mrkatz/laravel-query-detector) The Laravel N+1 query detector helps you to increase your application's performance by reducing the number of queries it executes. This package monitors your queries in real-time, while you develop your application and notify you when you should add eager loading (N+1 queries). @@ -15,7 +15,7 @@ The Laravel N+1 query detector helps you to increase your application's performa You can install the package via composer: ```bash -composer require beyondcode/laravel-query-detector --dev +composer require Mrkatz/laravel-query-detector --dev ``` The package will automatically register itself. diff --git a/composer.json b/composer.json index 23ff06e..5c87f6f 100644 --- a/composer.json +++ b/composer.json @@ -1,50 +1,54 @@ { - "name": "beyondcode/laravel-query-detector", + "name": "mrkatz/laravel-query-detector", "description": "Laravel N+1 Query Detector", + "version": "1.0.0", "keywords": [ - "beyondcode", + "mrkatz", "laravel-query-detector" ], - "homepage": "https://github.com/beyondcode/laravel-query-detector", + "homepage": "https://github.com/mrkatz/laravel-query-detector", "license": "MIT", "authors": [ { - "name": "Marcel Pociot", - "email": "marcel@beyondco.de", - "homepage": "https://beyondcode.de/", + "name": "Adam Kaczocha", + "email": "adamkaczocha@gmail.com", "role": "Developer" } ], "require": { "php": "^7.1 || ^8.0", - "illuminate/support": "^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0|^10.0" + "illuminate/support": "^6|^7|^8|^9|^10|^11" }, "require-dev": { "laravel/legacy-factories": "^1.0", - "orchestra/testbench": "^3.0 || ^4.0 || ^5.0 || ^6.0|^8.0", - "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + "orchestra/testbench": "~3.6.7 || ~3.7.8 || ~3.8.6 || ^4.8 || ^5.2 || ^6.0 || ^9.0", + "pestphp/pest": "^2.34", + "pestphp/pest-plugin-laravel": "^2.4" }, "autoload": { "psr-4": { - "BeyondCode\\QueryDetector\\": "src" + "Mrkatz\\QueryDetector\\": "src" } }, "autoload-dev": { "psr-4": { - "BeyondCode\\QueryDetector\\Tests\\": "tests" + "Mrkatz\\QueryDetector\\Tests\\": "tests" } }, "scripts": { - "test": "vendor/bin/phpunit", - "test-coverage": "vendor/bin/phpunit --coverage-html coverage" + "test": "vendor/bin/pest", + "test-coverage": "vendor/bin/pest --coverage-html coverage" }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "pestphp/pest-plugin": true + } }, "extra": { "laravel": { "providers": [ - "BeyondCode\\QueryDetector\\QueryDetectorServiceProvider" + "Mrkatz\\QueryDetector\\QueryDetectorServiceProvider" ] } } diff --git a/config/config.php b/config/config.php index 84f1765..69688b6 100644 --- a/config/config.php +++ b/config/config.php @@ -40,30 +40,30 @@ * * Alert: * Displays an alert on the website - * \BeyondCode\QueryDetector\Outputs\Alert::class + * \Mrkatz\QueryDetector\Outputs\Alert::class * * Console: * Writes the N+1 queries into your browsers console log - * \BeyondCode\QueryDetector\Outputs\Console::class + * \Mrkatz\QueryDetector\Outputs\Console::class * * Clockwork: (make sure you have the itsgoingd/clockwork package installed) * Writes the N+1 queries warnings to Clockwork log - * \BeyondCode\QueryDetector\Outputs\Clockwork::class + * \Mrkatz\QueryDetector\Outputs\Clockwork::class * * Debugbar: (make sure you have the barryvdh/laravel-debugbar package installed) * Writes the N+1 queries into a custom messages collector of Debugbar - * \BeyondCode\QueryDetector\Outputs\Debugbar::class + * \Mrkatz\QueryDetector\Outputs\Debugbar::class * * JSON: * Writes the N+1 queries into the response body of your JSON responses - * \BeyondCode\QueryDetector\Outputs\Json::class + * \Mrkatz\QueryDetector\Outputs\Json::class * * Log: * Writes the N+1 queries into the Laravel.log file - * \BeyondCode\QueryDetector\Outputs\Log::class + * \Mrkatz\QueryDetector\Outputs\Log::class */ 'output' => [ - \BeyondCode\QueryDetector\Outputs\Alert::class, - \BeyondCode\QueryDetector\Outputs\Log::class, + \Mrkatz\QueryDetector\Outputs\Alert::class, + \Mrkatz\QueryDetector\Outputs\Log::class, ] ]; diff --git a/docs/_index.md b/docs/_index.md index ed8a55e..5c1e32c 100644 --- a/docs/_index.md +++ b/docs/_index.md @@ -1,4 +1,4 @@ --- packageName: Laravel Query Detector -githubUrl: https://github.com/beyondcode/laravel-query-detector ---- \ No newline at end of file +githubUrl: https://github.com/mrkatz/laravel-query-detector +--- diff --git a/docs/installation.md b/docs/installation.md index 3559ca2..07e924a 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -11,7 +11,7 @@ The Laravel N+1 query detector helps you to increase your application's performa You can install the package via composer: ``` -composer require beyondcode/laravel-query-detector --dev +composer require mrkatz/laravel-query-detector --dev ``` -The package will automatically register itself. \ No newline at end of file +The package will automatically register itself. diff --git a/docs/usage.md b/docs/usage.md index be34cfd..be9902a 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -14,7 +14,7 @@ If you rather want this information to be written to your `laravel.log` file, wr You can publish the package's configuration using this command: ```bash -php artisan vendor:publish --provider="BeyondCode\QueryDetector\QueryDetectorServiceProvider" +php artisan vendor:publish --provider="Mrkatz\QueryDetector\QueryDetectorServiceProvider" ``` This will add the `querydetector.php` file in your config directory with the following contents: @@ -53,31 +53,31 @@ return [ * * Alert: * Displays an alert on the website - * \BeyondCode\QueryDetector\Outputs\Alert::class + * \Mrkatz\QueryDetector\Outputs\Alert::class * * Console: * Writes the N+1 queries into your browsers console log - * \BeyondCode\QueryDetector\Outputs\Console::class + * \Mrkatz\QueryDetector\Outputs\Console::class * * Clockwork: (make sure you have the itsgoingd/clockwork package installed) * Writes the N+1 queries warnings to Clockwork log - * \BeyondCode\QueryDetector\Outputs\Clockwork::class + * \Mrkatz\QueryDetector\Outputs\Clockwork::class * * Debugbar: (make sure you have the barryvdh/laravel-debugbar package installed) * Writes the N+1 queries into a custom messages collector of Debugbar - * \BeyondCode\QueryDetector\Outputs\Debugbar::class + * \Mrkatz\QueryDetector\Outputs\Debugbar::class * * JSON: * Writes the N+1 queries into the response body of your JSON responses - * \BeyondCode\QueryDetector\Outputs\Json::class + * \Mrkatz\QueryDetector\Outputs\Json::class * * Log: * Writes the N+1 queries into the Laravel.log file - * \BeyondCode\QueryDetector\Outputs\Log::class + * \Mrkatz\QueryDetector\Outputs\Log::class */ 'output' => [ - \BeyondCode\QueryDetector\Outputs\Log::class, - \BeyondCode\QueryDetector\Outputs\Alert::class, + \Mrkatz\QueryDetector\Outputs\Log::class, + \Mrkatz\QueryDetector\Outputs\Alert::class, ] ]; @@ -86,7 +86,7 @@ return [ If you use **Lumen**, you need to copy the config file manually and register the Lumen Service Provider in `bootstrap/app.php` file ```php -$app->register(\BeyondCode\QueryDetector\LumenQueryDetectorServiceProvider::class); +$app->register(\Mrkatz\QueryDetector\LumenQueryDetectorServiceProvider::class); ``` -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.) +If you need additional logic to run when the package detects unoptimized queries, you can listen to the `\Mrkatz\QueryDetector\Events\QueryDetected` event and write a listener to run your own handler. (e.g. send warning to Sentry/Bugsnag, send Slack notification, etc.) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 1eef57c..01d88f4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,29 +1,12 @@ - + tests - - - src/ - - - - - - - - - diff --git a/src/Events/QueryDetected.php b/src/Events/QueryDetected.php index 635ac4f..1db67e8 100644 --- a/src/Events/QueryDetected.php +++ b/src/Events/QueryDetected.php @@ -1,6 +1,6 @@ collector = new MessagesCollector('N+1 Queries'); - + if (!LaravelDebugbar::hasCollector($this->collector->getName())) { LaravelDebugbar::addCollector($this->collector); } diff --git a/src/Outputs/Json.php b/src/Outputs/Json.php index e2f5714..d9b1a28 100644 --- a/src/Outputs/Json.php +++ b/src/Outputs/Json.php @@ -1,5 +1,5 @@ setData($data); } diff --git a/src/Outputs/Log.php b/src/Outputs/Log.php index 7563530..5afffee 100644 --- a/src/Outputs/Log.php +++ b/src/Outputs/Log.php @@ -1,6 +1,6 @@ findSource($backtrace); - + if (empty($sources)) { return; } diff --git a/src/QueryDetectorMiddleware.php b/src/QueryDetectorMiddleware.php index df0d5de..662f87a 100644 --- a/src/QueryDetectorMiddleware.php +++ b/src/QueryDetectorMiddleware.php @@ -1,6 +1,6 @@ define(Post::class, function ($faker) { @@ -41,4 +41,4 @@ return [ 'body' => $faker->paragraph, ]; -}); \ No newline at end of file +}); diff --git a/tests/Models/Author.php b/tests/Models/Author.php index eebeda4..a710c8c 100644 --- a/tests/Models/Author.php +++ b/tests/Models/Author.php @@ -1,6 +1,6 @@ Date: Thu, 16 May 2024 13:38:33 +1000 Subject: [PATCH 2/3] Versioning --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 5c87f6f..f600814 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mrkatz/laravel-query-detector", "description": "Laravel N+1 Query Detector", - "version": "1.0.0", + "version": "1.9.0", "keywords": [ "mrkatz", "laravel-query-detector" @@ -16,7 +16,7 @@ } ], "require": { - "php": "^7.1 || ^8.0", + "php": "^7.1 || ^8.0 || ^8.2", "illuminate/support": "^6|^7|^8|^9|^10|^11" }, "require-dev": { From 547a1c53899c11accfe7f83de7ce7930e527a110 Mon Sep 17 00:00:00 2001 From: Adam Kaczocha Date: Thu, 16 May 2024 13:39:29 +1000 Subject: [PATCH 3/3] Versioning --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f600814..6c86904 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "mrkatz/laravel-query-detector", "description": "Laravel N+1 Query Detector", - "version": "1.9.0", + "version": "1.9.1", "keywords": [ "mrkatz", "laravel-query-detector"