PHP code example of pozitronik / yii2-exceptionslogger

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

    

pozitronik / yii2-exceptionslogger example snippets


try {
	$i = $i/0;
} catch (Throwable $t) {
	SysExceptions::log($t);//just silently log exception
	SysExceptions::log(new RuntimeException("Someone tried divide to zero"), false, true);//silently log own exception and mark it as known error
	SysExceptions::log(new RuntimeException("It prohibited by mathematics"), true);//log own exception and throw it
}


$config = [
    'components' => [
        'errorHandler' => [
            'class' => pozitronik\sys_exceptions\models\ErrorHandler::class,
            'errorAction' => 'site/error'
        ]
    ];

$config = [
        'modules' => [
            'SysExceptionsModule' => [
                'params' => [
                    'customDataHandler' => static function():string {
                        return Yii::$app->request?->csrfToken;//for example
                    }
                ]
            ],
        ]
    ]

php composer.phar