PHPackages                             xakki/phperrorcatcher - 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. xakki/phperrorcatcher

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

xakki/phperrorcatcher
=====================

PHP Logger - Monolog/PSR compatible

0.8.4(2mo ago)674GPL-3.0-or-laterPHPPHP ^8.3CI passing

Since Oct 25Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Xakki/PHPErrorCatcher)[ Packagist](https://packagist.org/packages/xakki/phperrorcatcher)[ Docs](https://xakki.github.io/phperrorcatcher/)[ RSS](/packages/xakki-phperrorcatcher/feed)WikiDiscussions master Synced 2w ago

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

PHPErrorCatcher
===============

[](#phperrorcatcher)

Logger for all PHP &amp; JS errors (PSR-3), with pluggable storage backends. Requires **PHP 8.3+**. Full runnable example: [`example/test.php`](https://github.com/Xakki/PHPErrorCatcher/blob/master/example/test.php).

📖 **[Documentation site](https://xakki.github.io/PHPErrorCatcher/)**

Install
-------

[](#install)

```
composer require xakki/phperrorcatcher
```

Init
----

[](#init)

Instantiate with named arguments. The constructor registers all error/exception/shutdown handlers and sets `static::$obj` (accessible as a singleton via `PhpErrorCatcher::init()` for legacy code):

```
use Xakki\PhpErrorCatcher\PhpErrorCatcher;

require_once 'vendor/autoload.php';

$logger = new PhpErrorCatcher(
    storage: [
        // any subset of: FileStorage, StreamStorage, SyslogStorage, ElasticStorage
        'StreamStorage' => ['stream' => 'php://stderr'],
    ],
    dirRoot:   __DIR__,
    debugMode: false,
);
```

> **Deprecated:** `PhpErrorCatcher::init(array $config)` still works for backward compatibility but will be removed in a future release. Prefer `new PhpErrorCatcher(...)` with named arguments.

From here every uncaught error, exception and `trigger_error()` is captured automatically.

Custom reporting
----------------

[](#custom-reporting)

The instance implements `Psr\Log\LoggerInterface`, so log manually with the standard PSR-3 methods. An exception can be passed straight as the message:

```
$logger->error('My custom error');     // custom message
$logger->critical($exception);         // log a caught \Throwable
trigger_error('msg', E_USER_WARNING);  // also captured by the handler
```

Browser (JS) errors
-------------------

[](#browser-js-errors)

`JsLogPlugin` catches browser errors (`window.onerror`, `console.error`, `unhandledrejection`, failed resource loads) and reports them to the PHP side. It skips bots/crawlers and noise (cross-origin `"Script error."`, browser extensions), de-duplicates, and attaches context (viewport, build version, anonymized breadcrumbs).

There are two ways to include the script.

**Static** — serve the bundled file as-is. The trigger key must match the client default `catcherLogName`, so set `initGetKey => 'catcherLogName'`:

```

errorCatcher('custom error');
```

**Dynamic (recommended)** — let `JsLogPlugin` serve the script with the trigger key (and an optional signed token) injected, so any `initGetKey` works. The response is cached for one day:

```

```

An optional `secret` in the plugin config enables a stateless HMAC token: the served script embeds a short-lived token that the server verifies on every log (no storage needed). Leave it empty to gate access by `initGetKey` only.

Web log viewer
--------------

[](#web-log-viewer)

When errors are persisted with `FileStorage`, `FileViewer` renders an HTML report to browse, download, back up and delete the stored log files. Register it via the `viewer` config and gate access with its own `initGetKey`:

```
'viewer' => [
    'class'      => 'FileViewer',
    'initGetKey' => 'changeMe5',
],
```

Then open the entry point with that key as a query parameter, e.g. `/?changeMe5=`.

Related projects
----------------

[](#related-projects)

- [**FluentLog**](https://github.com/Xakki/FluentLog) (`xakki/fluent-log`) — drop-in fluent-bit config that ships Docker container logs and on-disk log files to Graylog over GELF, and exposes fluent-bit metrics to Prometheus.
- [**LaraLog**](https://github.com/Xakki/LaraLog) (`xakki/laralog`) — structured production logging for Laravel: a drop-in `LogManager` with custom drivers, formatters and Monolog processors that enrich and safeguard every log record.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance88

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity73

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

Recently: every ~676 days

Total

6

Last Release

62d ago

PHP version history (4 changes)0.3.4PHP &gt;=5.4.0

0.4.8PHP &gt;=5.6

0.8.0PHP &gt;=8.0

0.8.4PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/426468?v=4)[Xakki](/maintainers/Xakki)[@Xakki](https://github.com/Xakki)

---

Top Contributors

[![Xakki](https://avatars.githubusercontent.com/u/426468?v=4)](https://github.com/Xakki "Xakki (57 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/xakki-phperrorcatcher/health.svg)

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

###  Alternatives

[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k382.4M3.6k](/packages/symfony-cache)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k39.6k](/packages/matomo-matomo)[illuminate/log

The Illuminate Log package.

6225.7M682](/packages/illuminate-log)[tempest/framework

The PHP framework that gets out of your way.

2.3k37.6k20](/packages/tempest-framework)[api-platform/metadata

API Resource-oriented metadata attributes and factories

275.5M254](/packages/api-platform-metadata)[pagemachine/typo3-formlog

Form log for TYPO3

23243.0k8](/packages/pagemachine-typo3-formlog)

PHPackages © 2026

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