PHP code example of jesugmz / http-health-check

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

    

jesugmz / http-health-check example snippets


use HttpHealthCheck\HttpHealthCheck;

$endpointUrl = 'https://github.com/jesuGMZ/';
$conditions = [
    'status_code_equals_to' => 200,
    'body_contains'         => 'jesuGMZ',
];

$check = new HttpHealthCheck($endpointUrl, $conditions);

var_dump($check->isHealthy());

use HttpHealthCheck\HttpHealthCheck;

$endpointUrl = 'https://mdn.github.io/learning-area/javascript/oojs/json/superheroes.json';
$conditions = [
    'status_code_equals_to' => 200,
    'body_contains'         => 'Super hero squad',
];
$options = [
    'headers' => [
        'User-Agent' => 'My custom user agent',
        'Accept'     => 'application/json',
    ]
];

$check = new HttpHealthCheck($endpointUrl, $conditions, $options);

var_dump($check->isHealthy());