PHPackages                             themosis/error - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. themosis/error

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

themosis/error
==============

The Themosis error component.

1.0.0(1y ago)11GPL-3.0-or-laterPHPPHP ^8.2

Since Feb 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/themosis/error)[ Packagist](https://packagist.org/packages/themosis/error)[ RSS](/packages/themosis-error/feed)WikiDiscussions main Synced 1mo ago

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

Themosis Error
==============

[](#themosis-error)

The Themosis error component provides a highly configurable PHP API to manage application errors and exceptions. The package also provides a nice looking and color accessible interface to better help you debug your web projects.

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

[](#installation)

Install the library using [Composer](https://getcomposer.org/):

```
composer require themosis/error
```

Features
--------

[](#features)

- Configurable error reporter
- Backtrace with filterable and identifiable frames
- File preview
- Supports nested exceptions
- HTML error report template with light and dark themes
- Configurable PHP error handler
- Configurable PHP exception handler

Example
-------

[](#example)

You can quickly try the example provided within the package by cloning the repository and run the PHP built-in web server:

```
git clone https://github.com/themosis/error.git
cd error/example
php -S localhost:8000
```

The `example` directory shows a code sample with a configured report handler hooked as the default PHP exception handler. The example code throws multiple exceptions and render them in the browser using the default HTML template. Feel free to explore!

Usage
-----

[](#usage)

The package provides 2 components to help you interact with PHP errors and exceptions:

1. [Report Handler](#report-handler)
    - [Reporters](#reporters)
    - [PHP Error Handler](#php-error-handler)
    - [PHP Exception Handler](#php-exception-handler)
    - [Issue](#issue)
    - [Information](#information)
    - [On Exceptions](#on-exceptions)
    - [On Issues](#on-issues)
2. [Backtrace](#backtrace)
    - [Capture Frames](#capture-frames)
    - [Get Frames](#get-frames)
    - [Tag Frames](#tag-frames)
    - [Filter Frames](#filter-frames)

Report Handler
--------------

[](#report-handler)

The `ReportHandler` is the main component of the package, it acts as an aggregate that manages how you can report your application errors and exceptions.

The `ReportHandler` class requires two dependencies:

1. A repository of reporters
2. A repository of issues

A `Reporter` is an interface that represents any PHP class that can report an `Issue`. For example, a reporter can report an issue to the standard output (stdout), or report the issue in a log file, or send the issue to a third-party service, ... The choice is yours. You can register as many reporters as you want. It is also possible to configure in which context a reporter can act against a given issue.

An `Issue` is an interface that represents an error or any custom problem in your application that you want to report.

Depending on your needs, you can configure multiple report handlers within your application. Here is a basic configuration example where we always report to the stdout:

```
