PHPackages                             scottsmith/error-handler - 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. scottsmith/error-handler

ActiveLibrary

scottsmith/error-handler
========================

Error/Exception handler

1.3.0(3y ago)05811MITPHPPHP ^7.4|^8.0

Since Nov 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/scottasmith/php-error-handler)[ Packagist](https://packagist.org/packages/scottsmith/error-handler)[ Docs](https://github.com/scottasmith/php-error-handler)[ RSS](/packages/scottsmith-error-handler/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (12)Used By (0)

PHP Error Reporter
==================

[](#php-error-reporter)

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

[](#installation)

```
composer require scottsmith/error-handler

```

Configuration
-------------

[](#configuration)

There are two main things to set to make the reporter work.

- The reporter
- Use the base handler

### Reporter

[](#reporter)

There are two supported reporters:

- NullReporter
- LaravelBugsnagReporter

The BugsnagReporter extends the `AbstractReporter`. This allows to extend the metadata:

```
$reporter->registerMetaGenerator(new class implements MetaGeneratorInterface {
    public function generateMetaData(): array
    {
        return ['some' => 'data'];
    }
}

```

Laravel Integration
===================

[](#laravel-integration)

Configuration
-------------

[](#configuration-1)

You need to publish the configuration using `php artisan vendor:publish`.

This allows to update the reporter the ModuleServiceProvider binds as ReporterInterface.

To use the bugsnag reporter you need to install and setup the `bugsnag/bugsnag-laravel` package.

The `app\Exceptions\Handler.php` needs to extend the `ScottSmith\ErrorHandler\Integration\Laravel\Handler` class.

By default, the reporter to be used is the `ScottSmith\ErrorHandler\Reporter\NullReporter`. To update the reported, simply update the published config `config\error-handler.php`:

```
    'reporter' => \ScottSmith\ErrorHandler\Reporter\LaravelBugsnagReporter::class,

```

If the reporter extends `AbstractReporter` then you can extend the global data inside your Provider:

```
class AppServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->extend(\ScottSmith\ErrorHandler\Reporter\AbstractReporter::class, function($reporter) {
            $reporter->registerMetaGenerator(new class implements MetaGeneratorInterface {
                public function generateMetaData(): array
                {
                    return ['some' => 'data'];
                }
            }
        });
    }
}

```

Laminas/Mezzio Integration
==========================

[](#laminasmezzio-integration)

Configuration
-------------

[](#configuration-2)

If you are using the `laminas-component-installer` the module `ConfigProvider` should be added automatically. If not then you will have to add the `ScottSmith\ErrorHandler\Integration\Mezzio\ConfigProvider` manually. eg. config.php

```
$aggregator = new ConfigAggregator(
    [
        \ScottSmith\ErrorHandler\Integration\Laminas\ConfigProvider::class
        ...
    ]
);

```

You will then need to create configuration for the service manager. This README only covers the laminas service-manager. Create a file named `config\autoload\error.global.php`

```
