承接 phpsafari/health-checks 相关项目开发

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

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

phpsafari/health-checks

Composer 安装命令:

composer require phpsafari/health-checks

包简介

Make health checks in your laravel application

README 文档

README

Build Status

Add health checks to your Laravel applications with this package.

Examples

All passed DB failed Queue failed Url stats

Install

First, use Composer to install this package.

$ composer require phpsafari/health-checks

After the package has been installed, go ahead and add ``PhpSafari\ServiceProvider\HealthCheckServiceProvider::classto yourconfig/app.php` file.

After doing this, you can publish the health.php configuration file into your config folder by running:

$ php artisan vendor:publish --tag=health

Usage

Inside the config/health.php file is where you configure all your available health checks. By default, this package comes packed with a few checks already:

  • CorrectEnvironment will check if your application's environment is set to production
  • DatabaseOnline will check your database connection
  • DatabaseUpToDate will check if your application has any migrations that hasn't been migrated yet
  • DebugModeOff will check if debug mode is off
  • QueueProcessing will check if the queue is running and jobs are getting processed
  • PathIsWritable will check if a provided path is writable
  • LogLevel will check if log level is set to the given value
  • MaxRatioOf500Responses will check if the ratio of 500 response are above a given threshold (The last 60 min)
  • MaxResponseTimeAvg will check if average response time for all request are above a given threshold (The last 60 min)

To run a health check of your application, run:

$ php artisan health:check

You can also use Laravel's scheduler to schedule your health checks:

$schedule->command('health:check')->hourly();

Url based health checks

You can also run a health check by hitting the https://<APP_URL>/_health url in a browser or with a tool like Pingdom.

Note: _This feature can be disabled in the config/health.php file, by setting route.enabled to false.

You can navigate to https://<APP_URL>/_health/stats and get all stats, including avg response time,

Creating your own health checks

In order to create your own health checks, you just need to extend the PhpSafari\Checks\HealthCheck class and implement the run() method.

Example:

class IsFriday extends PhpSafari\Checks\HealthCheck
{
    public function run(): bool
    {
        return Carbon::now()->isFriday();
    }
}

Then add new IsFriday() to the list of checks in config/health.php.

Testing

$ phpunit tests/

Security

If you discover any security related issues, please email :author_email instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 13.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 37
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 37
  • Watchers: 1
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固