1. Go to this page and download the library: Download 68publishers/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/ */
68publishers / health-check example snippets
use SixtyEightPublishers\HealthCheck\ExportMode;
use SixtyEightPublishers\HealthCheck\HealthChecker;
use SixtyEightPublishers\HealthCheck\ServiceChecker\PDOServiceChecker;
use SixtyEightPublishers\HealthCheck\ServiceChecker\RedisServiceChecker;
$checker = new HealthChecker();
$checker->addServiceChecker(new PDOServiceChecker('pgsql:host=127.0.0.1;port=5432;dbname=example', 'user', 'password'));
$checker->addServiceChecker(new RedisServiceChecker())
# check all services
$result = $checker->check();
# you can throw an exception
if (!$result->isOk()) {
throw $result->getError();
}
# or covert the result into a JSON
echo json_encode($result);
# check Redis only
$result = $checker->check(['redis']);
# check in the "Full" mode. The default mode is "Simple".
$result = $checker->check(NULL, ExportMode::Full);
# the result now contains detailed information about each service
echo json_encode($result);
namespace App;
use Nette\Application\Routers\RouteList;
use SixtyEightPublishers\HealthCheck\Bridge\Nette\Application\HealthCheckRoute;
class RouteFactory {
public static function create(): RouteList {
$router = new RouteList();
$router->add(new HealthCheckRoute('/health-check'));
# ... other routes ...
return $router;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.