1. Go to this page and download the library: Download eqs/health-check-provider 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/ */
eqs / health-check-provider example snippets
use Doctrine\DBAL\Connection;
use GuzzleHttp\Psr7\HttpFactory;
use EQS\HealthCheckProvider\DTO\CheckDetails;
use EQS\HealthCheckProvider\DTO\HealthResponse;
use EQS\HealthCheckProvider\HealthChecker\CallableHealthChecker;
use EQS\HealthCheckProvider\HealthChecker\DoctrineConnectionHealthChecker;
use EQS\HealthCheckProvider\HealthChecker\HttpHealthChecker;
use EQS\HealthCheckProvider\RequestHandler;
use Psr\Http\Client\ClientInterface;
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Messenger\Transport\Receiver\MessageCountAwareInterface;
use Symfony\Component\Messenger\Transport\TransportInterface;
use Symfony\Component\Routing\Annotation\Route;
class GetHealthCheckController extends AbstractController
{
public function __construct(
#[Autowire(service: 'messenger.transport.amqp_dc_user_update')]
private MessageCountAwareInterface&TransportInterface $transport,
private Connection $connection,
private ClientInterface $httpClient,
) {}
#[Route(path: '/api/health_check')]
public function __invoke(Request $request): Response
{
$psr17Factory = new HttpFactory();
$psrBridge = new HttpFoundationFactory();
return $psrBridge->createResponse(
(new RequestHandler(
new HealthResponse(),
[
new CallableHealthChecker(new CheckDetails('AMQP', true), fn () => $this->transport->getMessageCount()),
new DoctrineConnectionHealthChecker(new CheckDetails('Database', true), $this->connection),
new HttpHealthChecker(
new CheckDetails('External API', false),
$this->httpClient,
new \GuzzleHttp\Psr7\Request('GET', 'https://www.google.com'),
),
],
$psr17Factory,
$psr17Factory,
))
->handle((new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory))
->createRequest($request)),
);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.