PHPackages                             jield-webdev/laminas-psr-doctrine-error-hero-module - 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. jield-webdev/laminas-psr-doctrine-error-hero-module

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

jield-webdev/laminas-psr-doctrine-error-hero-module
===================================================

A Hero for your Laminas and Mezzio application to trap php errors &amp; exceptions

07.0k↓15.8%PHPCI passing

Since Oct 24Pushed 1y agoCompare

[ Source](https://github.com/jield-webdev/laminas-psr-doctrine-error-hero-module)[ Packagist](https://packagist.org/packages/jield-webdev/laminas-psr-doctrine-error-hero-module)[ RSS](/packages/jield-webdev-laminas-psr-doctrine-error-hero-module/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

ErrorHeroModule
===============

[](#errorheromodule)

[![Latest Version](https://camo.githubusercontent.com/a09aee828216a9481717e74c31667bb85f98b0d6ad92215d3174f07e4ee57814/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73616d736f6e6173696b2f4572726f724865726f4d6f64756c652e7376673f7374796c653d666c61742d737175617265)](https://github.com/samsonasik/ErrorHeroModule/releases)[![ci build](https://github.com/samsonasik/ErrorHeroModule/workflows/ci%20build/badge.svg)](https://github.com/samsonasik/ErrorHeroModule/workflows/ci%20build/badge.svg)[![Code Coverage](https://camo.githubusercontent.com/77f6551f98399f7a0674e59bb4e106a86cad8b8bf7c6cb00f295342bca86565c/68747470733a2f2f636f6465636f762e696f2f67682f73616d736f6e6173696b2f4572726f724865726f4d6f64756c652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/samsonasik/ErrorHeroModule)[![PHPStan](https://camo.githubusercontent.com/fdcdf50c27377a0f41a7196eeaae8539c4684bfc8a1f9843fdac60fdbc53deab/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c2532306d61782d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265266c6162656c3d7068707374616e)](https://github.com/phpstan/phpstan)[![Downloads](https://camo.githubusercontent.com/ebf5fdbf9ce19753596824979b0417499c427b318026fdfb8451ef9a77c78b5c/68747470733a2f2f706f7365722e707567782e6f72672f73616d736f6e6173696b2f6572726f722d6865726f2d6d6f64756c652f646f776e6c6f616473)](https://packagist.org/packages/samsonasik/error-hero-module)

> This is a fork of [ErrorHeroModule](https://github.com/samsonasik/ErrorHeroModule)by [samsonasik](https://github.com/samsonasik) that has been updated to support PSR loggers and Doctrine

> This is README for version ^5.0 which only support Laminas Mvc version 3 and Mezzio version 3 with php ^8.1.

> For version ^4.0, you can read at [version 4 readme](https://github.com/samsonasik/ErrorHeroModule/tree/4.x.x) which only support Laminas Mvc version 3 and Mezzio version 3 with php ^8.0.

Introduction
------------

[](#introduction)

ErrorHeroModule is a module for Error Logging (DB and Mail) your Laminas Mvc 3 Application, and Mezzio 3 for Exceptions in 'dispatch.error' or 'render.error' or during request and response, and [PHP E\_\* Error](http://www.php.net/manual/en/errorfunc.constants.php).

Features
--------

[](#features)

- Save to DB with Db Writer Adapter.
- Log Exception (dispatch.error and render.error) and PHP Errors in all events process.
- Support excludes [PHP E\_\* Error](http://www.php.net/manual/en/errorfunc.constants.php) (eg: exclude E\_USER\_DEPRECATED or specific E\_USER\_DEPRECATED with specific message) in config settings.
- Support excludes [PHP Exception](http://php.net/manual/en/spl.exceptions.php) (eg: Exception class or classes that extends it or specific exception class with specific message) in config settings.
- Handle only once log error for same error per configured time range.
- Set default page (web access) or default message (console access) for error if configured 'display\_errors' = 0.
- Set default content when request is XMLHttpRequest via 'ajax' configuration.
- Set default content when there is [no template service](https://github.com/mezzio/mezzio-template/blob/9b6c2e06f8c1d7e43750f72b64cc749552f2bdbe/src/TemplateRendererInterface.php)via 'no\_template' configuration (Mezzio 3).
- Provide request information ( http method, raw data, body data, query data, files data, cookie data, and ip address).
- Send Mail
    - many receivers to listed configured email
    - with include $\_FILES into attachments on upload error (configurable to be included or not).

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

[](#installation)

**1. Import the following SQL for Mysql**

```
DROP TABLE IF EXISTS `log`;

CREATE TABLE `log`
(
    `id`           bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
    `date`         timestamp           NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    `type`         int(11)             NOT NULL,
    `event`        text                NOT NULL,
    `url`          varchar(2000)       NOT NULL,
    `file`         varchar(2000)       NOT NULL,
    `line`         int(11)             NOT NULL,
    `error_type`   varchar(255)        NOT NULL,
    `trace`        text                NULL,
    `request_data` text                NULL,
    PRIMARY KEY (`id`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = latin1;
```

> If you use other RDBMS, you may follow the `log` table structure above.

**2. Setup your Laminas\\Db\\Adapter\\AdapterInterface service or your Doctrine\\ORM\\EntityManager service config**

You can use 'db' (with *Laminas\\Db*) config or 'doctrine' (with *DoctrineORMModule*) config that will be transformed to be usable with `Laminas\Log\Writer\Db`.

```
