PHP code example of fruitcake / magento2-health-check

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

    

fruitcake / magento2-health-check example snippets


use Fruitcake\HealthCheck\Model\CheckResult;
use Fruitcake\HealthCheck\Observer\AbstractCheck;

class Erp extends AbstractCheck
{
    // Add a constructor with your own dependencies; pass Config on to parent::__construct()


    public function getCode(): string
    {
        return 'erp';
    }

    protected function check(): CheckResult
    {
        return $this->isConnected()
            ? CheckResult::ok()
            : CheckResult::failed('ERP is not reachable');
    }
}

composer magento module:enable Fruitcake_HealthCheck
php bin/magento setup:upgrade
xml
<type name="Fruitcake\HealthCheck\Observer\Check\SearchEngine">
    <arguments>
        <argument name="testers" xsi:type="array">
            <item name="mirasvit" xsi:type="object">Vendor\Module\Model\MirasvitConnectionTester</item>
        </argument>
    </arguments>
</type>
xml
<type name="Fruitcake\HealthCheck\Model\Format\FormatPool">
    <arguments>
        <argument name="formats" xsi:type="array">
            <item name="prometheus" xsi:type="object">Vendor\Module\Model\PrometheusFormat</item>
        </argument>
    </arguments>
</type>