1. Go to this page and download the library: Download browncat/healthcheck-bundle 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/ */
browncat / healthcheck-bundle example snippets
// src/Check/ExampleCheck.php
namespace App\Check;
use Browncat\HealthCheckBundle\Check\HealthCheck;
use Browncat\HealthCheckBundle\Checker\LivenessChecker;
use Browncat\HealthCheckBundle\Checker\ReadinessChecker;
use Psr\Container\ContainerInterface;
final class ExampleCheck extends HealthCheck
{
// Name of the health check
protected $name = 'example:connection';
// List of checkers who should execute this check.
public static $checkers = [ReadinessChecker::class, LivenessChecker::class];
public function __construct(ContainerInterface $container)
{
if ($container->has('example')) {
$exampleService = $container->get('example');
if (!$exampleService->isConnected()) {
$this->succeeded = false;
$this->reasonPhrase = "Could not establish connection to example " . $connection->getName() . ".";
} else {
$this->succeeded = true;
}
} else {
$this->skipped = true;
$this->reasonPhrase = "example is not installed so this check is skipped.";
}
}
}
// src/Check/ExampleCheck.php
use Browncat\HealthCheckBundle\Check\HealthCheck;
final class ExampleCheck extends HealthCheck
{
protected $name = 'example:connection';
...
}
// src/Check/ExampleCheck.php
...
use Browncat\HealthCheckBundle\Check\HealthCheck;
...
final class ExampleCheck extends HealthCheck
{
public function __construct(SomeService $someService)
{
if ($someService->isLoaded() {
$this->succeeded = true
} else {
$this->succeeded = false;
// (optional) set a reason for the failed test
$this->reasonPhrase = "SomeService Could not be loaded!";
}
}
}
// src/Check/ExampleCheck.php
...
use Browncat\HealthCheckBundle\Check\HealthCheck;
use Psr\Container\ContainerInterface;
...
final class ExampleCheck extends HealthCheck
{
public function __construct(ContainerInterface $container)
{
if (!$container->has('someService')) {
$this->skipped = true;
$this->reasonPhrase = 'SomeService is skipped because it does not exist.';
}
...
}
}
// src/Check/ExampleCheck.php
use Browncat\HealthCheckBundle\Check\HealthCheck;
use Browncat\HealthCheckBundle\Checker\ReadinessChecker;
final class ExampleCheck extends HealthCheck
{
public static $checkers = [ReadinessChecker::class];
...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.