PHPackages                             microparts/errors-php - 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. microparts/errors-php

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

microparts/errors-php
=====================

Is a complex solution to handling exceptions for any web application.

1.0.1(7y ago)03GPL-3.0-onlyPHPPHP &gt;=7.2

Since May 2Pushed 5y ago2 watchersCompare

[ Source](https://github.com/microparts/errors-php)[ Packagist](https://packagist.org/packages/microparts/errors-php)[ RSS](/packages/microparts-errors-php/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

This package moved to
-----------------------------------------------------------------

[](#this-package-moved-to-httpsgithubcomspacetab-ioerrors-php)

Errors PHP package
==================

[](#errors-php-package)

[![CircleCI](https://camo.githubusercontent.com/843e3410e68d073c8394b21c015d008dce7abbcb9db7813b9a36d7c78605e103/68747470733a2f2f636972636c6563692e636f6d2f67682f6d6963726f70617274732f6572726f72732d7068702e7376673f7374796c653d737667)](https://circleci.com/gh/microparts/errors-php)[![codecov](https://camo.githubusercontent.com/badcc11cf945cefa44a4292a32b54d36a920b8912f41c216d8a597dab521de58/68747470733a2f2f636f6465636f762e696f2f67682f6d6963726f70617274732f6572726f72732d7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/microparts/errors-php)

Is a complex solution to handling exceptions for any web application. Compatible with [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) (logger) and [PSR-7](http://www.php-fig.org/psr/psr-7/) (http messages) recommendations.

Key features:

- Framework agnostic (can be integrated with any php web app);
- You can define custom validation and error format for http response;
- You can define custom error handler;
- You can send error messages (debug output) to any service (sentry, bugsnag), classic logger or use both together;
- You can replace sensitivity data from exception message (like sql-queries in PDOException);
- You can mark exception like "silent" and it will be don't report to notification channels;
- 100% tests coverage :)

Install
-------

[](#install)

As usual, install it through composer:

```
composer require microparts/errors-php
```

Usage
-----

[](#usage)

Library does not handle errors globally. So that it works for you it needs a configure in application service provider.

Example how to does it:

```
// Simple example for most cases
use Microparts\Errors\Error;

$error = Error::new($debug = true); // debug parameter add exception trace to http error response.
```

By default will be registered `PDOException` as "masked" and it exception message will be replaced with "Database error occurred. See logs for details.". Also default `ValidationException` will be registered as "silent" for skip notifications about user mistakes.

Second step is a exception capture in place where your app handle errors:

```
use Microparts\Errors\Error;

$error = Error::new($debug = true);

try {
    throw new PDOException('test');
} catch (Throwable $e) {
    return $error->capture($e); // return PSR ResponseInterface
}
```

Method `capture` returns a PSR ResponseInterface with formatted response to provide it to user.

Hard usage
----------

[](#hard-usage)

Hard in quotes of course :)

`Error` object may be configured what you like. Example:

```
// Simple example for most cases
use Microparts\Errors\Error;
use Microparts\Errors\Notify\LoggerNotify;
use Microparts\Errors\Notify\SentryNotify;
use Microparts\Logger\Logger;
use Microparts\Errors\Formatter\DefaultErrorFormatter;
use Microparts\Errors\Handler\DefaultErrorHandler;

$error = new Error($debug = false);
$error->setFormatter(new DefaultErrorFormatter($debug));
$error->setHandler(new DefaultErrorHandler());
$error->addSilentException(LogicException::class); // logic is not a need thing
$error->addDatabaseException(RedisException::class);
// Logger PSR compatible.
// If you want use my pretty logger, just run command:
// composer require microparts/logs-php
$error->addNotifier(new LoggerNotify(Logger::new()));
$error->addNotifier(new SentryNotify(['dsn' => $dsn]));
```

That all. Use with ❤.

Sentry &amp; Notify both channels
---------------------------------

[](#sentry--notify-both-channels)

Sentry integration available. Install sentry sdk through composer:

```
composer require sentry/sdk
```

...and then register new notifier:

```
use Microparts\Errors\Error;
use Microparts\Errors\Notify\LoggerNotify;
use Microparts\Errors\Notify\SentryNotify;
use Microparts\Logger\Logger;

$error = Error::new();
$error->addNotifier(new LoggerNotify(Logger::new()));
$error->addNotifier(new SentryNotify(['dsn' => $dsn]));
```

Two notifies will be works together and send notifications to both channels. Now you should be capture exceptions in the try/catch block.

Tests
-----

[](#tests)

- 100% tests coverage
- `vendor/bin/phpunit`

License
-------

[](#license)

The MIT License

Copyright © 2019 teamc.io, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

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

Total

2

Last Release

2569d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/35d8eff4a3e66b58f3e2af56fe948035469de1e19ac29c532d65c681955bbd18?d=identicon)[Roquie](/maintainers/Roquie)

---

Top Contributors

[![roquie](https://avatars.githubusercontent.com/u/3214290?v=4)](https://github.com/roquie "roquie (11 commits)")

---

Tags

errorsexceptionsframework-agnosticmonologphp7psr-3psr-7sentryvalidation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/microparts-errors-php/health.svg)

```
[![Health](https://phpackages.com/badges/microparts-errors-php/health.svg)](https://phpackages.com/packages/microparts-errors-php)
```

###  Alternatives

[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2222.9M248](/packages/open-telemetry-sdk)[pagemachine/typo3-formlog

Form log for TYPO3

23225.3k6](/packages/pagemachine-typo3-formlog)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[illuminated/console-logger

Logging and Notifications for Laravel Console Commands.

8674.9k](/packages/illuminated-console-logger)[scoutapp/scout-apm-php

Scout Application Performance Monitoring Agent - https://scoutapm.com

17877.0k5](/packages/scoutapp-scout-apm-php)[open-telemetry/opentelemetry-auto-wordpress

OpenTelemetry auto-instrumentation for Wordpress

17166.0k](/packages/open-telemetry-opentelemetry-auto-wordpress)

PHPackages © 2026

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