PHP code example of jtl / health-check

1. Go to this page and download the library: Download jtl/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/ */

    

jtl / health-check example snippets

 


use Jtl\HealthCheck\AbstractHealthCheck;
use Jtl\HealthCheck\Result;
use Jtl\HealthCheck\ResultDetail;
use Jtl\HealthCheck\ResultMessage;

$healthCheck = new class extends AbstractHealthCheck {
    public function check(): Result
    {
        $passed = true;

        $details = [
            new ResultDetail('app', true),
            new ResultDetail('db', true),
        ];

        $messages =  [
            new ResultMessage('info', 'app', 'Everything is tutti')
        ];

        return new Result($passed, $details, $messages);
    }
};

//Outputs a json response with either http status 200 or 500.
$healthCheck->checkAndSendResult();