PHPackages                             atournayre/exception-handler - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. atournayre/exception-handler

Abandoned → [symfony/symfony](/?search=symfony%2Fsymfony)Library[Logging &amp; Monitoring](/categories/logging)

atournayre/exception-handler
============================

Centralized exception handling with Symfony and custom PHP attributes

1.1.0(3y ago)02.6kMITPHPPHP &gt;=8.1

Since Dec 14Pushed 2y ago1 watchersCompare

[ Source](https://github.com/atournayre/exception-handler)[ Packagist](https://packagist.org/packages/atournayre/exception-handler)[ RSS](/packages/atournayre-exception-handler/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

Exception Handler Component for Symfony
=======================================

[](#exception-handler-component-for-symfony)

This component helps handle exceptions inside Symfony.

It is inspired from the article [Centralized exception handling with Symfony and custom PHP attributes ](https://angelovdejan.me/2022/11/24/centralized-exception-handling-with-symfony-and-custom-php-attributes.html) by [Dejan Angelov](https://github.com/angelov). Read it before!

Install
-------

[](#install)

### Composer

[](#composer)

```
composer require atournayre/exception-handler
```

### Usage

[](#usage)

1. Define `HttpStatusCodeExceptionHandler` as a listener in your application.
2. Declare attributes on your existing/new exceptions classes.
3. Remove (or do not catch exception) in your controller.
4. It works!

#### Define `HttpStatusCodeExceptionHandler` as a listener in your application

[](#define-httpstatuscodeexceptionhandler-as-a-listener-in-your-application)

```
# config/services.yaml
services:
  Atournayre\Component\ExceptionHandler\Handler\HttpStatusCodeExceptionHandler:
    tags:
      - { name: kernel.event_listener, event: kernel.exception }
```

#### Declare attributes on your existing/new exceptions classes.

[](#declare-attributes-on-your-existingnew-exceptions-classes)

```
// Example for a NotFound (404)
#[NotFound]
class OrderNotFound extends Exception
{
    public function __construct(OrderId $id)
    {
        parent::__construct(
            sprintf('The order "%s" could not be found.', (string) $id)
        );
    }
}
```

```
// Example for a UnprocessableEntity (422)
#[UnprocessableEntity]
class OrderAlreadyShipped extends Exception { ... }
```

```
// Example for a Forbidden (403)
#[Forbidden]
class CustomerMismatch extends Exception { ... }
```

Contributing
------------

[](#contributing)

Of course, open source is fueled by everyone's ability to give just a little bit of their time for the greater good. If you'd like to see a feature or add some of your *own* happy words, awesome! Tou can request it - but creating a pull request is an even better way to get things done.

Either way, please feel comfortable submitting issues or pull requests: all contributions and questions are warmly appreciated :).

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.5% 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

Every ~132 days

Total

2

Last Release

1155d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/be702ea3d10de6d97d83c32866fc9cfe1830a055e7f8b685c8434ccad40416c1?d=identicon)[atournayre](/maintainers/atournayre)

---

Top Contributors

[![atournayre](https://avatars.githubusercontent.com/u/4262077?v=4)](https://github.com/atournayre "atournayre (21 commits)")[![mend-bolt-for-github[bot]](https://avatars.githubusercontent.com/in/16809?v=4)](https://github.com/mend-bolt-for-github[bot] "mend-bolt-for-github[bot] (1 commits)")

---

Tags

componentexceptionexception-handlingexceptionssymfony

### Embed Badge

![Health badge](/badges/atournayre-exception-handler/health.svg)

```
[![Health](https://phpackages.com/badges/atournayre-exception-handler/health.svg)](https://phpackages.com/packages/atournayre-exception-handler)
```

###  Alternatives

[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k246.0M11.1k](/packages/symfony-framework-bundle)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M373](/packages/easycorp-easyadmin-bundle)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k181.3M2.2k](/packages/symfony-security-bundle)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19564.8M1.6k](/packages/drupal-core)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6941.5M396](/packages/drupal-core-recommended)

PHPackages © 2026

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