1. Go to this page and download the library: Download ukfast/laravel-health-check library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
if (HealthCheck::passes('env')) {
// check passed
}
if (HealthCheck::fails('http')) {
// check failed
}
$numberOfChecks = HealthCheck::all()->count();
/**
* A list of middleware to run on the health-check route
* It's recommended that you have a middleware that only
* allows admin consumers to see the endpoint.
*
* See UKFast\HealthCheck\Middleware\BasicAuth for a one-size-fits all
* solution
*/
'middleware' => [
App\Http\Middleware\CustomMiddleware::class
],
if (HealthCheck::passes('env')) {
// check passed
}
if (HealthCheck::fails('http')) {
// check failed
}
$numberOfChecks = HealthCheck::all()->count();
return [
/**
* Base path for the health check endpoints, by default will use /
*/
'base-path' => '',
/**
* List of health checks to run when determining the health
* of the service
*/
'checks' => [
UKFast\HealthCheck\Checks\LogHealthCheck::class,
UKFast\HealthCheck\Checks\DatabaseHealthCheck::class,
UKFast\HealthCheck\Checks\EnvHealthCheck::class
],
/**
* A list of middleware to run on the health-check route
* It's recommended that you have a middleware that only
* allows admin consumers to see the endpoint.
*
* See UKFast\HealthCheck\BasicAuth for a one-size-fits all
* solution
*/
'middleware' => [],
/**
* Used by the basic auth middleware
*/
'auth' => [
'user' => env('HEALTH_CHECK_USER'),
'password' => env('HEALTH_CHECK_PASSWORD'),
],
/**
* Can define a list of connection names to test. Names can be
* found in your config/database.php file. By default, we just
* check the 'default' connection
*/
'database' => [
'connections' => ['default'],
],
/**
* Can give an array of nfig can be put here. For example, a health check
* for your .env file needs to know which keys need to be present.
* You can pass this information by specifying a new key here then
* accessing it via config('healthcheck.env') in your healthcheck class
*/
];
$app->configure('healthcheck');
/**
* A list of middleware to run on the health-check route
* It's recommended that you have a middleware that only
* allows admin consumers to see the endpoint.
*
* See UKFast\HealthCheck\BasicAuth for a one-size-fits all
* solution
*/
'middleware' => [
App\Http\Middleware\CustomMiddleware::class
],