PHPackages                             fyre/error - 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. fyre/error

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

fyre/error
==========

An error handling library.

v6.1.11(9mo ago)01734MITPHP

Since Apr 3Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyreError)[ Packagist](https://packagist.org/packages/fyre/error)[ RSS](/packages/fyre-error/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (9)Versions (28)Used By (4)

FyreError
=========

[](#fyreerror)

**FyreError** is a free, open-source error handling library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
- [Middleware](#middleware)
- [Exceptions](#exceptions)
    - [Http Exceptions](#http-exceptions)

Installation
------------

[](#installation)

**Using Composer**

```
composer require fyre/error

```

In PHP:

```
use Fyre\Error\ErrorHandler;
```

Basic Usage
-----------

[](#basic-usage)

- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).
- `$io` is a [*Console*](https://github.com/elusivecodes/FyreConsole).
- `$logManager` is a [*LogManager*](https://github.com/elusivecodes/FyreLog).
- `$eventManager` is an [*EventManager*](https://github.com/elusivecodes/FyreEvent).
- `$config` is a [*Config*](https://github.com/elusivecodes/FyreConfig).

```
$errorHandler = new ErrorHandler($container, $io, $logManager, $eventManager, $config);
```

Default configuration options will be resolved from the "*Error*" key in the [*Config*](https://github.com/elusivecodes/FyreConfig).

- `$options` is an array containing the configuration options.
    - `level` is a number representing the error reporting level, and will default to `E_ALL`.
    - `renderer` is a *Closure* that will be used to render an *Exception*, and will default to *null*.
    - `log` is a boolean indicating whether to log exception messages, and will default to *true*.

```
$container->use(Config::class)->set('Error', $options);
```

**Autoloading**

It is recommended to bind the *ErrorHandler* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.

```
$container->singleton(ErrorHandler::class);
```

Any dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$errorHandler = $container->use(ErrorHandler::class);
```

Methods
-------

[](#methods)

**Disable CLI**

Disable CLI error handling.

```
$errorHandler->disableCli();
```

**Enable CLI**

Enable CLI error handling.

```
$errorHandler->enableCli();
```

**Get Exception**

Get the current *Exception*.

```
$exception = $errorHandler->getException();
```

**Get Renderer**

Get the error renderer.

```
$renderer = $errorHandler->getRenderer();
```

**Register**

Register the error handler.

```
$errorHandler->register();
```

**Render**

Render an *Exception*.

```
$response = $errorHandler->render($exception);
```

**Set Renderer**

Set the error renderer.

- `$renderer` is a *Closure* that accepts an *Exception* as the first argument.

```
$errorHandler->setRenderer($renderer);
```

The renderer should return a [*ClientResponse*](https://github.com/elusivecodes/FyreServer#client-responses) or a string.

**Unregister**

Unregister the error handler.

```
$errorHandler->unregister();
```

Middleware
----------

[](#middleware)

```
use Fyre\Error\Middleware\ErrorHandlerMiddleware;
```

- `$errorHandler` is an *ErrorHandler*.

```
$middleware = new ErrorHandlerMiddleware($errorHandler);
```

Any dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$middleware = $container->use(ErrorHandlerMiddleware::class);
```

**Handle**

- `$request` is a [*ServerRequest*](https://github.com/elusivecodes/FyreServer#server-requests).
- `$next` is a *Closure*.

```
$response = $middleware->handle($request, $next);
```

This method will return a [*ClientResponse*](https://github.com/elusivecodes/FyreServer#client-responses).

Exceptions
----------

[](#exceptions)

Custom exceptions can be created by extending the `Fyre\Error\Exceptions\Exception` class.

- `$message` is a string representing the error message.
- `$code` is a number representing the error code, and will default to *500*.
- `$previous` is an *Exception* representing the previous exception, and will default to *null*.

```
new Exception($message, $code, $previous);
```

### Http Exceptions

[](#http-exceptions)

**Bad Request**

400 Bad Request error.

```
use Fyre\Error\Exceptions\BadRequestException;
```

**Unauthorized**

401 Unauthorized error.

```
use Fyre\Error\Exceptions\UnauthorizedException;
```

**Forbidden**

403 Forbidden error.

```
use Fyre\Error\Exceptions\Forbidden;
```

**Not Found**

404 Not Found error.

```
use Fyre\Error\Exceptions\NotFoundException;
```

**Method Not Allowed**

405 Method Not Allowed error.

```
use Fyre\Error\Exceptions\MethodNotAllowedException;
```

**Not Acceptable**

406 Not Acceptable error.

```
use Fyre\Error\Exceptions\NotAcceptableException;
```

**Conflict**

409 Conflict error.

```
use Fyre\Error\Exceptions\ConflictException;
```

**Gone**

410 Gone error.

```
use Fyre\Error\Exceptions\GoneException;
```

**Internal Server**

500 Internal Server error.

```
use Fyre\Error\Exceptions\InternalServerException;
```

**Not Implemented**

501 Not Implemented error.

```
use Fyre\Error\Exceptions\NotImplementedException;
```

**Service Unavailable**

503 Service Unavailable error.

```
use Fyre\Error\Exceptions\ServiceUnavailableException;
```

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance56

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~48 days

Recently: every ~36 days

Total

27

Last Release

291d ago

Major Versions

v1.0 → v2.02022-07-04

v2.0.1 → v3.02023-08-09

v3.0.2 → v4.02024-06-08

v4.0.5 → v5.02024-11-12

v5.0.1 → v6.02024-11-17

### Community

Maintainers

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

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (27 commits)")

---

Tags

errorexceptionphp

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/fyre-error/health.svg)

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

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B10.9k](/packages/psr-log)[open-telemetry/api

API for OpenTelemetry PHP.

1938.5M261](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2326.5M315](/packages/open-telemetry-sdk)

PHPackages © 2026

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