2017 © Pedro PelĂĄez
 

library health-checks

Make health checks in your laravel application

image

phpsafari/health-checks

Make health checks in your laravel application

  • Friday, December 8, 2017
  • by vistik
  • Repository
  • 1 Watchers
  • 7 Stars
  • 489 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 7 Open issues
  • 8 Versions
  • 33 % Grown

The README.md

Health Checks

Build Status, (*1)

Add health checks to your Laravel applications with this package., (*2)

Examples

All passed DB failed Queue failed Url stats, (*3)

Install

First, use Composer to install this package., (*4)

$ composer require phpsafari/health-checks

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

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

$ 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:, (*7)

  • 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:, (*8)

$ php artisan health:check

You can also use Laravel's scheduler to schedule your health checks:, (*9)

$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., (*10)

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

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

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., (*13)

Example:, (*14)

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., (*15)

Testing

bash $ phpunit tests/, (*16)

Security

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

Credits

License

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

The Versions

08/12 2017

dev-master

9999999-dev

Make health checks in your laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Visti Kløft

08/12 2017

v0.0.7

0.0.7.0

Make health checks in your laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Visti Kløft

18/08 2017

v0.0.6

0.0.6.0

Make health checks in your laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Visti Kløft

28/07 2017

v0.0.5

0.0.5.0

Make health checks in your laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Visti Kløft

13/02 2017

v0.0.4

0.0.4.0

Make health checks in your laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Visti Kløft

13/02 2017

v0.0.3

0.0.3.0

Make health checks in your laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Visti Kløft

13/02 2017

v0.0.2

0.0.2.0

Make health checks in your laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Visti Kløft

13/02 2017

v0.0.1

0.0.1.0

Make health checks in your laravel application

  Sources   Download

MIT

The Requires

 

The Development Requires

by Visti Kløft