PHP code example of developeruz / yii2-custom-errorhandler
1. Go to this page and download the library: Download developeruz/yii2-custom-errorhandler 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/ */
developeruz / yii2-custom-errorhandler example snippets
'components' => [
...
'errorHandler' => [
'errorAction' => 'site/error',
],
...
public function actions()
{
return [
'error' => [
'class' => 'developeruz\yii2_custom_errorhandler\ErrorHandler',
'array_of_exceptions' => [
403 => function()
{
return $this->redirect(Url::to('/site/login'));
},
500 => function()
{
//send notification to administrator
...
return $this->redirect(Url::to('/site/index'));
},
]
]
];
}
bash
$ php composer.phar