1. Go to this page and download the library: Download kgaut/healthcheck 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/ */
kgaut / healthcheck example snippets
// Search API critique en production seulement.
$config['healthcheck.settings']['checks']['search_api']['critical'] = TRUE;
// Le test d'écriture dans un autre dossier.
$config['healthcheck.settings']['files_directory'] = 'private://healthcheck';
namespace Drupal\mon_module\Plugin\HealthCheck;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\healthcheck\Attribute\HealthCheck;
use Drupal\healthcheck\CheckResult;
use Drupal\healthcheck\HealthCheckBase;
#[HealthCheck(id: 'mon_service', label: new TranslatableMarkup('Mon service'), critical: TRUE, weight: 40)]
final class MonService extends HealthCheckBase {
public function check(): CheckResult {
// Interroger réellement le service, avec un délai court.
return CheckResult::ok();
}
}
yaml
window: 30 # durée de vie d'un verdict, en secondes
files_directory: 'public://.healthcheck' # dossier du test d'écriture
checks:
search_api:
critical: true # rendre Search API critique sur ce site : un Solr en panne → 503
files:
enabled: false # ne pas jouer cette vérification sur ce site
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.