PHPackages                             temant-framework/temant-fault - 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. [Framework](/categories/framework)
4. /
5. temant-framework/temant-fault

ActiveLibrary[Framework](/categories/framework)

temant-framework/temant-fault
=============================

A modern, feature-rich exception handler for PHP with HTML, JSON, XML, and plain text rendering. Part of the Temant Framework.

v1.0.0(today)01—0%MITPHPPHP &gt;=8.5CI passing

Since Mar 21Pushed todayCompare

[ Source](https://github.com/Temant-Framework/Temant-Fault)[ Packagist](https://packagist.org/packages/temant-framework/temant-fault)[ Docs](https://github.com/temant-framework/temant-fault)[ RSS](/packages/temant-framework-temant-fault/feed)WikiDiscussions main Synced today

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

 **Temant Fault**

 A modern, feature-rich exception handler for PHP.

 [![CI](https://github.com/EmadAlmahdi/Temant-Fault/actions/workflows/ci.yml/badge.svg)](https://github.com/EmadAlmahdi/Temant-Fault/actions/workflows/ci.yml) [![Coverage](https://camo.githubusercontent.com/6699b332ba39066ba514740832f2ecc5a955c80e0c5918ad8663ddbd6604b975/68747470733a2f2f636f6465636f762e696f2f67682f74656d616e742d6672616d65776f726b2f74656d616e742d6661756c742f67726170682f62616467652e737667)](https://codecov.io/gh/temant-framework/temant-fault) [![Latest Version](https://camo.githubusercontent.com/b6f6f6d545c62d1c35e3ea91d61a66f60bf790237780e82b45de984c830b59d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74656d616e742d6672616d65776f726b2f74656d616e742d6661756c742e737667)](https://packagist.org/packages/temant-framework/temant-fault) [![Total Downloads](https://camo.githubusercontent.com/42544af6f8b7d921ae700de0b4919ae4084ac78a68f7d9ff2eddb65ad3ed045e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74656d616e742d6672616d65776f726b2f74656d616e742d6661756c742e737667)](https://packagist.org/packages/temant-framework/temant-fault) [![PHP Version](https://camo.githubusercontent.com/afcb9c08e2ef5ff13da8cf233e416ab1d45eaaf5f355190ce114ac132c0ecc28/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f74656d616e742d6672616d65776f726b2f74656d616e742d6661756c742e737667)](https://packagist.org/packages/temant-framework/temant-fault) [![License](https://camo.githubusercontent.com/483b704773aefc6c9fe47e7ee7ed3a161ca699e7591bae988dfcd6f8543a5d59/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74656d616e742d6672616d65776f726b2f74656d616e742d6661756c742e737667)](https://github.com/EmadAlmahdi/Temant-Fault/blob/main/LICENSE) [![PHPStan Level 9](https://camo.githubusercontent.com/1bc07920f0d36e55c17e1d38b1caa132cc605f51a82b388c962870b9a747b898/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d627269676874677265656e2e737667)](https://phpstan.org/)

---

**Fault** is an exception handler that catches uncaught exceptions and PHP errors, then renders beautiful, information-rich error pages. It supports HTML, JSON, XML, and plain text output with automatic content negotiation. Part of the [Temant Framework](https://github.com/temant-framework).

Features
--------

[](#features)

- Interactive HTML error page with syntax-highlighted source code
- Stack trace sidebar with frame filtering and keyboard navigation
- Tabbed debug panels: Request, Environment, Session, Cookies, Logs, Git, Xdebug
- JSON, XML, and plain text renderers for APIs and CLI
- Automatic content negotiation via HTTP Accept header
- Light/dark theme with localStorage persistence
- "Open in editor" links (PHPStorm, VS Code, Sublime, Atom, IntelliJ, NetBeans)
- Sensitive data masking (passwords, API keys, tokens)
- Exception chain support with full previous-exception rendering
- Listener callbacks for logging and external error reporting
- Production mode with safe, detail-free error pages
- PHPStan level 9 strict typing

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Extensions: `json`, `mbstring`, `xmlwriter`

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

[](#installation)

```
composer require temant-framework/temant-fault
```

Quick Start
-----------

[](#quick-start)

```
use TemantFramework\Fault\ExceptionHandler;

$handler = new ExceptionHandler();
$handler
    ->setDebug(true)
    ->setApplicationName('My App')
    ->setEditor('vscode')
    ->register();

// That's it. Any uncaught exception will now render a rich error page.
```

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

```
use TemantFramework\Fault\ExceptionHandler;

$handler = new ExceptionHandler();
$handler->setDebug(true)->register();
```

### Production Mode

[](#production-mode)

In production, disable debug mode to show a safe, generic error page:

```
$handler->setDebug(false)->register();
```

### Editor Integration

[](#editor-integration)

Configure clickable "Open in editor" links for your IDE:

```
// Supported: phpstorm, vscode, sublime, atom, idea, netbeans
$handler->setEditor('phpstorm');
```

### Listener Callbacks

[](#listener-callbacks)

Add listeners to log or report exceptions before rendering:

```
$handler->addListener(function (\Throwable $e): void {
    error_log($e->getMessage());
});

$handler->addListener(function (\Throwable $e): void {
    Sentry::captureException($e);
});
```

### Custom Renderers

[](#custom-renderers)

Replace any built-in renderer with your own:

```
use TemantFramework\Fault\ContentType;
use TemantFramework\Fault\Renderer\RendererInterface;
use TemantFramework\Fault\ErrorContext;

$handler->setRenderer(ContentType::Json, new class implements RendererInterface {
    public function render(ErrorContext $context, bool $debug = true): string
    {
        return json_encode(['error' => $context->message]);
    }

    public function contentType(): string
    {
        return 'application/json';
    }
});
```

### Programmatic Rendering

[](#programmatic-rendering)

Render exceptions without outputting them:

```
use TemantFramework\Fault\ContentType;

$html = $handler->render($exception, ContentType::Html);
$json = $handler->render($exception, ContentType::Json);
$xml  = $handler->render($exception, ContentType::Xml);
$text = $handler->render($exception, ContentType::Text);
```

### Default Content Type

[](#default-content-type)

Change the fallback format when content negotiation has no match:

```
use TemantFramework\Fault\ContentType;

$handler->setDefaultContentType(ContentType::Json);
```

Renderers
---------

[](#renderers)

RendererContent TypeDebug OutputProduction Output`HtmlRenderer``text/html`Interactive debug pageMinimal 500 page`JsonRenderer``application/json`Full error JSON`{"error": {"message": "Internal Server Error"}}``XmlRenderer``application/xml`Full error XML`Internal Server Error``PlainTextRenderer``text/plain`Stack trace text`Internal Server Error`Keyboard Shortcuts (HTML Renderer)
----------------------------------

[](#keyboard-shortcuts-html-renderer)

KeyAction`j` / `k` or Arrow keysNavigate stack frames`/`Focus frame search`t`Toggle light/dark theme`c`Copy error to clipboardDevelopment
-----------

[](#development)

```
# Install dependencies
composer install

# Run tests
composer phpunit

# Run static analysis
composer phpstan

# Run all checks
composer test

# Generate coverage report
composer coverage
```

Project Structure
-----------------

[](#project-structure)

```
fault/
├── src/
│   ├── ContentType.php          # Content type enum with negotiation
│   ├── ErrorContext.php          # Immutable exception data container
│   ├── ExceptionHandler.php     # Central handler (main entry point)
│   └── Renderer/
│       ├── RendererInterface.php # Renderer contract
│       ├── HtmlRenderer.php     # Rich interactive HTML pages
│       ├── JsonRenderer.php     # Structured JSON output
│       ├── XmlRenderer.php      # Well-formed XML documents
│       └── PlainTextRenderer.php# Plain text for CLI/logs
├── tests/
│   └── Unit/                    # PHPUnit test suite
├── examples/
│   └── basic.php                # Usage example
├── build/                       # Cache, coverage (gitignored)
├── composer.json
├── phpunit.xml
├── phpstan.neon                 # PHPStan level 9
└── LICENSE                      # MIT

```

License
-------

[](#license)

Fault is open-source software licensed under the [MIT License](LICENSE).

Part of the [Temant Framework](https://github.com/temant-framework).

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

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

---

Top Contributors

[![EmadAlmahdi](https://avatars.githubusercontent.com/u/135208774?v=4)](https://github.com/EmadAlmahdi "EmadAlmahdi (9 commits)")

---

Tags

frameworkdebugexceptionerrorwhoopshandlererror-handlerexception handlerfaulttemant

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/temant-framework-temant-fault/health.svg)

```
[![Health](https://phpackages.com/badges/temant-framework-temant-fault/health.svg)](https://phpackages.com/packages/temant-framework-temant-fault)
```

###  Alternatives

[graham-campbell/exceptions

Provides A Powerful Error Response System For Both Development And Production

5861.2M3](/packages/graham-campbell-exceptions)[lanin/laravel-api-debugger

Easily debug your JSON API.

2311.8M](/packages/lanin-laravel-api-debugger)[kuria/error

Makes handling and debugging PHP errors suck less

2119.7k2](/packages/kuria-error)[topshelfcraft/canary

The kinder, cuter, cleverer Craft error handler.

114.4k](/packages/topshelfcraft-canary)

PHPackages © 2026

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