PHPackages                             webservco/exception - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. webservco/exception

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

webservco/exception
===================

A PHP component/library.

v1.0.0(1y ago)03821MITPHPPHP ^8.4

Since Jul 2Pushed 1y ago1 watchersCompare

[ Source](https://github.com/webservco/exception)[ Packagist](https://packagist.org/packages/webservco/exception)[ Docs](https://webserv.co)[ RSS](/packages/webservco-exception/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (17)Versions (5)Used By (1)

webservco/exception
===================

[](#webservcoexception)

A PHP component/library.

Custom application exception handling.

---

Usage
-----

[](#usage)

Implement interfaces:

### `ExceptionHandlerFactoryInterface`

[](#exceptionhandlerfactoryinterface)

```
interface ExceptionHandlerFactoryInterface
{
    public function createExceptionHandler(LoggerInterface $logger): ExceptionHandlerInterface;
}
```

### `ExceptionHandlerInterface`

[](#exceptionhandlerinterface)

```
interface ExceptionHandlerInterface
{
    public function handle(Throwable $throwable): void;
}
```

### `UncaughtExceptionHandlerInterface`

[](#uncaughtexceptionhandlerinterface)

```
interface UncaughtExceptionHandlerInterface extends ExceptionHandlerInterface
{
}
```

---

Example implementation
----------------------

[](#example-implementation)

### Handle uncaught exceptions.

[](#handle-uncaught-exceptions)

In application bootstrap:

```
// Exception handling.
$exceptionHandlerFactory = new DefaultExceptionHandlerFactory();
// Uncaught exception handler.
set_exception_handler([$exceptionHandlerFactory->createUncaughtExceptionHandler($logger), 'handle']);
```

### Handle exceptions inside the application (caught exceptions)

[](#handle-exceptions-inside-the-application-caught-exceptions)

In application logic:

```
$exceptionHandler = $exceptionHandlerFactory->createExceptionHandler($logger);

// Example: an exception handling middleware.
final class ExceptionHandlerMiddleware implements MiddlewareInterface
{
    public function __construct(
        // Exception handler to use to handle the exception.
        private ExceptionHandlerInterface $exceptionHandler,
        // Request handler to use to return a response to the client
        private RequestHandlerInterface $requestHandler,
    ) {
    }

    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        try {
            /**
             * Pass to the next handler.
             * If all is OK, nothing else to do.
             */
            return $handler->handle($request);
        } catch (Throwable $throwable) {
            /**
             * An exception happened inside one of the next handlers.
             */

            // Handle error (log, report, etc)
            $this->exceptionHandler->handle($throwable);

            /**
             * Return a response via the request handler.
             * Any exceptions that happen here will bubble up and be handled by the uncaught exception handler (if set).
             */
            return $this->requestHandler->handle($request->withAttribute('throwable', $throwable));
        }
    }
}
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance43

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

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

Every ~198 days

Total

4

Last Release

457d ago

Major Versions

v0.8.0 → v1.0.02025-02-15

PHP version history (3 changes)v0.0.1PHP ^8.2

v0.8.0PHP ^8.3

v1.0.0PHP ^8.4

### Community

Maintainers

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

---

Top Contributors

[![ariademur](https://avatars.githubusercontent.com/u/34913107?v=4)](https://github.com/ariademur "ariademur (32 commits)")

---

Tags

componentwebservco

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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