PHPackages                             swiftyper/emperror-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. swiftyper/emperror-php

ActiveLibrary

swiftyper/emperror-php
======================

Provides an error handler for PHP that can execute a stack of handlers for various purposes.

1.0.0(today)020↑2600%MITPHPPHP ^7.2 || ^8.0CI passing

Since Aug 14Pushed todayCompare

[ Source](https://github.com/swiftyper-sk/emperror-php)[ Packagist](https://packagist.org/packages/swiftyper/emperror-php)[ RSS](/packages/swiftyper-emperror-php/feed)WikiDiscussions main Synced today

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

[![EMPERROR logo](emperror.svg)](emperror.svg)

Emperror PHP
============

[](#emperror-php)

PHP error catcher and handler for [swiftyper.sk](https://swiftyper.sk).

Emperror catches PHP exceptions, errors, warnings, and notices.

📖 Requirements
--------------

[](#-requirements)

- PHP 7.2 or higher
- PHP extensions: `curl`, `json`
- [Composer](https://getcomposer.org) is required for installation

📦 Installing
------------

[](#-installing)

```
$ composer require swiftyper/emperror-php
```

⚡️ Quick Start
--------------

[](#️-quick-start)

### Configuration

[](#configuration)

```
\Swiftyper\Emperror::setup([
    'apiKey' => 'your api key'
]);
```

```
\Swiftyper\Emperror::get()
    ->setUser([
        'name' => 'user name',
        'photo' => 'user photo',
    ])
    ->setContext([
        'orderId' => 1234,
    ]);
```

### Send events and exceptions manually

[](#send-events-and-exceptions-manually)

Use `sendException()` to send any caught exception:

```
try {
    throw new Exception("Payment processing error", 1);
} catch (Exception $e) {
    \Swiftyper\Emperror::get()->sendException($e);
}
```

Use `sendMessage()` to send a plain message with optional context - ideal for logs, notices, or anything that isn't an exception:

```
\Swiftyper\Emperror::get()->sendMessage('Payment webhook received twice', [
    'webhookId' => $webhookId,
]);
```

Use `sendEvent()` when you need full control over the raw event payload:

```
\Swiftyper\Catcher::get()->sendEvent([
    'title'   => 'Custom event title',
    'context' => [
        'orderId' => 1234,
    ],
]);
```

### Filtering sensitive information

[](#filtering-sensitive-information)

Emperror already filter a few obvious things for you before an event ever leaves your server:

- Sensitive request headers - `Authorization`, `Cookie`, `Proxy-Authorization`, `X-Api-Key`, `X-Auth-Token`, `X-Csrf-Token` - are replaced with `[Filtered]`.
- Function/method arguments whose name looks like a secret (`password`, `token`, `secret`, `apiKey`, `auth`, ...) are replaced with `[Filtered]` in stack traces.

For anything else - user emails, custom context fields, or your own payloads - use the `beforeSend` hook. Use the `EventPayload` getters/setters to inspect or clear any property before it's sent:

```
\Swiftyper\Emperror::setup([
    // ...
    'beforeSend' => function (\Swiftyper\EventPayload $eventPayload) {
        $user = $eventPayload->getUser();

        if (!empty($user['email'])){
            unset($user['email']);

            $eventPayload->setUser($user);
        }

        return $eventPayload;
    }
]);
```

🧪 Testing
---------

[](#-testing)

```
$ composer tests
```

🤝 Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

📜 License
---------

[](#-license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance100

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3dd2a282ad197d4dc306ad1fc38c4873f3763f91cbe099b0af74e3dc4cac558a?d=identicon)[swiftyper](/maintainers/swiftyper)

---

Top Contributors

[![richardDobron](https://avatars.githubusercontent.com/u/33115305?v=4)](https://github.com/richardDobron "richardDobron (2 commits)")

---

Tags

phperrorcatcher

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/swiftyper-emperror-php/health.svg)

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

###  Alternatives

[brianium/paratest

Parallel testing for PHP

2.5k142.8M1.1k](/packages/brianium-paratest)[doctrine/mongodb-odm

PHP Doctrine MongoDB Object Document Mapper (ODM) provides transparent persistence for PHP objects to MongoDB.

1.1k24.8M382](/packages/doctrine-mongodb-odm)[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1871.6M3](/packages/justbetter-magento2-sentry)[codex-team/hawk.php

PHP errors Catcher module for Hawk.so

2235.8k2](/packages/codex-team-hawkphp)[thehocinesaad/laravel-error-ai

This package adds Ask AI button to the error page.

2234.1k](/packages/thehocinesaad-laravel-error-ai)

PHPackages © 2026

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