PHP code example of arrilot / bitrix-systemcheck

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

    

arrilot / bitrix-systemcheck example snippets


class BitrixDebugIsTurnedOn extends Check
{
    /**
     * @return string
     */
    public function name()
    {
        return "Проверка на exception_handling.debug = true ...";
    }

    /**
     * @return boolean
     */
    public function run()
    {
        $config = Configuration::getInstance()->get('exception_handling');

        if (empty($config['debug'])) {
            $this->logError('Значение конфигурации exception_handling.debug должно быть true в данном окружении');
            return false;
        }

        return true;
    }
}

class FullMonitoring extends Monitoring
{
    /**
     * Russian monitoring name
     *
     * @return string
     */
    public function name()
    {
        return 'Полный мониторинг';
    }

    /**
     * Monitoring code (id)
     *
     * @return string
     */
    public function code()
    {
        return 'full';
    }

    /**
     * @return array
     */
    public function checks()
    {
        if (in_production()) {
            return [
                new BitrixChecks\RequiredPhpModules(),
                new BitrixChecks\PhpSettings(),
                ...
        }

        return [
            new BitrixChecks\RequiredPhpModules(),
            new BitrixChecks\PhpSettings(),
            ...
        ];
    }

    /**
     * @return Logger|null|\Psr\Log\LoggerInterface
     */
    public function logger()
    {
        $logger = new Logger('monitoring-full');
        $logger->pushHandler(new StreamHandler(logs_path('systemcheck/monitoring-full.log')));

        return $logger;
    }
}

'bitrix-systemcheck' => [
    'value' => [
        'monitorings' => [
            \System\SystemCheck\Monitorings\FullMonitoring::class,
            \System\SystemCheck\Monitorings\BriefMonitoring::class,
        ]
    ],
    'readonly' => true,
],