PHPackages                             spencer-mortensen/exceptions - 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. spencer-mortensen/exceptions

ActiveLibrary

spencer-mortensen/exceptions
============================

Catch fatal errors and warnings that would otherwise be difficult to handle

6.0.3(1y ago)039.6k↓32.9%4LGPL-3.0-or-laterPHPPHP &gt;=5.6.0

Since Jan 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Spencer-Mortensen/exceptions)[ Packagist](https://packagist.org/packages/spencer-mortensen/exceptions)[ Docs](https://github.com/spencer-mortensen/exceptions)[ RSS](/packages/spencer-mortensen-exceptions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (19)Used By (4)

Exceptions
==========

[](#exceptions)

This project is available as a Composer Package:
[spencer-mortensen/exceptions](https://packagist.org/packages/spencer-mortensen/exceptions)

Overview
--------

[](#overview)

Error handling in PHP is [complicated](https://spencermortensen.com/articles/php-error-handling/), but this library makes it bullet-proof: Create a method to handle exceptions (e.g. `$handler->handle($throwable);`) and you're good to go!

This library converts all PHP notices, warnings, and errors into exceptions, so you can handle them. It also works on any thrown exceptions that make it up to the global scope. It even catches most of the fatal errors, which would otherwise be impossible to handle.

Usage
-----

[](#usage)

Example 1. Enable error handling for the entire program:

```
new ErrorHandling($errorHandler, E_ALL);
```

Example 2. Enable error handling ONLY for your portion of the code:

```
try {
	ErrorHandling::on();
	...
} finally {
	ErrorHandling::off();
}
```

This converts PHP notices, warnings, and errors into catchable exceptions, but *only* for the duration of the try/catch block.

Example 3. Show the built-in PHP STDERR messages, so you can see errors while you're working on your error handler. If you're working on your error handler, and you're getting a blank screen, use this:

```
new ErrorHandling($errorHandler, E_ALL, false);
```

When you're finished, set everything back to normal:

```
new ErrorHandling($errorHandler, E_ALL);
```

See the [example](https://github.com/spencer-mortensen/exceptions/tree/master/example) area for working code and ideas.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance50

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

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

Recently: every ~501 days

Total

18

Last Release

367d ago

Major Versions

1.0.0 → 2.0.02018-01-05

2.0.2 → 3.0.02018-06-27

3.2.2 → 4.0.02019-08-21

4.0.1 → 5.0.02019-11-18

5.0.0 → 6.0.02022-12-27

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

3.0.0PHP &gt;=5.6.0

### Community

Maintainers

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

---

Top Contributors

[![spencer-mortensen](https://avatars.githubusercontent.com/u/2017476?v=4)](https://github.com/spencer-mortensen "spencer-mortensen (25 commits)")

---

Tags

exceptions

### Embed Badge

![Health badge](/badges/spencer-mortensen-exceptions/health.svg)

```
[![Health](https://phpackages.com/badges/spencer-mortensen-exceptions/health.svg)](https://phpackages.com/packages/spencer-mortensen-exceptions)
```

###  Alternatives

[bugsnag/bugsnag-laravel

Official Bugsnag notifier for Laravel applications.

90334.6M36](/packages/bugsnag-bugsnag-laravel)[bugsnag/bugsnag

Official Bugsnag notifier for PHP applications.

56347.0M78](/packages/bugsnag-bugsnag)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M82](/packages/rollbar-rollbar)[graham-campbell/exceptions

Provides A Powerful Error Response System For Both Development And Production

5911.3M4](/packages/graham-campbell-exceptions)[bugsnag/bugsnag-symfony

Official BugSnag notifier for Symfony applications.

453.0M3](/packages/bugsnag-bugsnag-symfony)

PHPackages © 2026

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