PHPackages                             developeruz/yii2-custom-errorhandler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. developeruz/yii2-custom-errorhandler

ActiveYii2-extension[Security](/categories/security)

developeruz/yii2-custom-errorhandler
====================================

Custom error handler for Yii 2.x application

1.0.0(10y ago)76961MITPHP

Since Sep 24Pushed 10y ago2 watchersCompare

[ Source](https://github.com/developeruz/yii2-custom-errorhandler)[ Packagist](https://packagist.org/packages/developeruz/yii2-custom-errorhandler)[ RSS](/packages/developeruz-yii2-custom-errorhandler/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Кастомная обработка ошибок в приложениях Yii 2.x
================================================

[](#кастомная-обработка-ошибок-в-приложениях-yii-2x)

Модуль позволяет повесить свою обработку на исключения (Exception).

\###Когда это нужно### Например для отлавливания "опасных" действий пользователя. При возникновении ошибки, вы можете залогировать данные и отследить частоту ForbiddenHttpException или NotFoundHttpException для конкретного пользователя или IP. Таким образом своевременно заблокировать пользователя и/или сообщить администратору о попытке взлома приложения. Самый простой из способов использования модуля - при получении ForbiddenHttpException проверить залогинен ли юзер и если нет - то отправить его на страницу авторизации.

\###Установка:###

```
$ php composer.phar require developeruz/yii2-custom-errorhandler "*"
```

\###Настройка:###

- В конфиге приложения прописываем action который будет вызываться при возникновении ошибок

```
 'components' => [
 ...
    'errorHandler' => [
       'errorAction' => 'site/error',
    ],
 ...
```

- Настраиваем action, указанный на предыдущем шаге. В моем примере пишем в site контроллер:

```
 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'));
                    },
                ]
            ]
        ];
    }
```

Теперь при возникновении ForbiddenHttpException пользователя будет перекидывать на страницу авторизации. Если обработка ошибки не описана в array\_of\_exceptions, то она обработается ErrorAction, указанным в параметре $defaultErrorAction (по умолчанию yii\\web\\ErrorAction)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3936d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b19e4f376a7fc95ccaf38274dc7768c7216d419b75b5a6da5d935c5d8521db3?d=identicon)[DeveloperUz](/maintainers/DeveloperUz)

---

Top Contributors

[![developeruz](https://avatars.githubusercontent.com/u/8788118?v=4)](https://github.com/developeruz "developeruz (3 commits)")

---

Tags

securityerror-handleryii2yii

### Embed Badge

![Health badge](/badges/developeruz-yii2-custom-errorhandler/health.svg)

```
[![Health](https://phpackages.com/badges/developeruz-yii2-custom-errorhandler/health.svg)](https://phpackages.com/packages/developeruz-yii2-custom-errorhandler)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
