承接 sofa/laravel-db-queries-alert 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sofa/laravel-db-queries-alert

Composer 安装命令:

composer require sofa/laravel-db-queries-alert

包简介

Insanely simple check against DB querying abuse in Laravel app AKA Check Your Queries Bro!

README 文档

README

aka Check Your Queries Bro!

Downloads stable

Laravel & Eloquent are beautiful and easy to use. Many packages make things even easier, which is brilliant! There's price to that though. Often you may find yourself in a situation when your app slows down or freezes completely without any significant change in the code. One of the reasons to that might be database querying abuse by hitting N+1 query problem on Eloquent relations, or some magic setup in a package you're using somewhere.

This package will help you with this problem by checking queries being run and logging info|warning|error when specified thresholds are exceeded.

Aim of the package is simply alerting you, without getting into details. It provides you some hints on where to look at, and either you spot the problem yourself right away, or you would resort to more in-depth analysis with laravel-debugbar, blackfire, xdebug or any other tool of your choice.

Usage

After you installed the package you can customize the thresholds publish configuration by calling:

$ php artisan vendor:publish --provider="Sofa\DbQueriesAlert\ServiceProvider"

and edit it in config/db_queries_alert.php:

return [
    'error' => 100,
    'warning' => 50,
    'info' => 20,
];

Now you're good to go. The package will call Log::error (or warning|info) whenever your app hits given threshold. Catch this error in the monitoring service you're using for the application (or simply check your local storage/logs/laravel[-YYYY-MM-DD].log file).

Note

This package depends fully on Laravel and is supposed to be used only there, thus there's no DI, it shamelessly uses facades and helpers and does not even try to hide it ¯\(ツ)

Installation

  1. Add package to your project:

    path/to/your/app$ composer require sofa/laravel-db-queries-alert
    
  2. Then add provider manually to your config/app.php:

    Package supports auto-discovery so this step is required only for Laravel 5.4.

    // config/app.php
    
        'providers' => [
            ...
            Sofa\DbQueriesAlert\ServiceProvider::class,
        ],
  3. Add entry to the global middleware stack in app/Http/Kernel.php file and flag to your .env file:

    // app/Http/Kernel.php
    class Kernel extends HttpKernel
    {
        /**
         * The application's global HTTP middleware stack.
         *
         * These are run for every single Request.
         *
         * @var array
         */
        protected $middleware = [
            ...
            \Sofa\DbQueriesAlert\Middleware::class,
        ];
    
    
    
    // .env
    DB_QUERIES_ALERT_ENABLED=true

Contribution

All contributions are welcome, PRs must be PSR-2 compliant.

统计信息

  • 总下载量: 2.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-06-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固