Download the PHP package samsonasik/error-hero-module without Composer
On this page you can find all versions of the php package samsonasik/error-hero-module. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download samsonasik/error-hero-module
More information about samsonasik/error-hero-module
Files in samsonasik/error-hero-module
Package error-hero-module
Short Description A Hero for your Laminas and Mezzio application to trap php errors & exceptions
License MIT
Homepage https://github.com/samsonasik/ErrorHeroModule
Informations about the package error-hero-module
ErrorHeroModule
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 which only support Laminas Mvc version 3 and Mezzio version 3 with php ^8.0.
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.
Features
- [x] Save to DB with Db Writer Adapter.
- [x] Log Exception (dispatch.error and render.error) and PHP Errors in all events process.
- [x] Support excludes PHP E_* Error (eg: exclude E_USER_DEPRECATED or specific E_USER_DEPRECATED with specific message) in config settings.
- [x] Support excludes PHP Exception (eg: Exception class or classes that extends it or specific exception class with specific message) in config settings.
- [x] Handle only once log error for same error per configured time range.
- [x] Set default page (web access) or default message (console access) for error if configured 'display_errors' = 0.
- [x] Set default content when request is XMLHttpRequest via 'ajax' configuration.
- [x] Set default content when there is no template service via 'no_template' configuration (Mezzio 3).
- [x] Provide request information ( http method, raw data, body data, query data, files data, cookie data, and ip address).
- [x] Send Mail
- [x] many receivers to listed configured email
- [x] with include $_FILES into attachments on upload error (configurable to be included or not).
Installation
1. Import the following SQL for Mysql
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
.
OR
If you use other RDBMS, you may configure your own
db
ordoctrine
config.
3. Require this module uses composer.
4. Copy config
a. For Laminas Mvc application, copy error-hero-module.local.php.dist
config to your local's autoload and configure it
source | destination |
---|---|
vendor/samsonasik/error-hero-module/config/error-hero-module.local.php.dist | config/autoload/error-hero-module.local.php |
Or run copy command:
b. For Mezzio application, copy mezzio-error-hero-module.local.php.dist
config to your local's autoload and configure it
source | destination |
---|---|
vendor/samsonasik/error-hero-module/config/mezzio-error-hero-module.local.php.dist | config/autoload/mezzio-error-hero-module.local.php |
Or run copy command:
When done, you can modify logger service named ErrorHeroModuleLogger
and error-hero-module
config in your's local config:
5. Lastly, enable it
a. For Laminas Mvc application
b. For Mezzio application
For laminas-mezzio-skeleton ^3.0.0, you need to open config/pipeline.php
and add the ErrorHeroModule\Middleware\Mezzio::class
middleware after default ErrorHandler::class
registration:
and also add error-preview
routes in config/routes.php
(optional) :
to enable error preview page. To disable error preview page, just remove it from routes.
Give it a try!
Web Access
URl | Preview For |
---|---|
http://yourlaminasormezzioapp/error-preview | Exception |
http://yourlaminasormezzioapp/error-preview/error | Error |
http://yourlaminasormezzioapp/error-preview/warning | PHP E_WARNING |
http://yourlaminasormezzioapp/error-preview/fatal | PHP Fatal Error |
You will get the following page if display_errors config is 0:
Console Access
You can use this module in
laminas-cli
, you can install:
then you can see the error-preview console:
Command | Preview For |
---|---|
vendor/bin/laminas errorheromodule:preview | Exception |
vendor/bin/laminas errorheromodule:preview error | Error |
vendor/bin/laminas errorheromodule:preview warning | PHP E_WARNING |
vendor/bin/laminas errorheromodule:preview fatal | PHP Fatal |
You will get the following page if display_errors config is 0:
You can use the error handling in your console application, by extends BaseLoggingCommand
, like below:
and register to your services like in the documentation.
For production env, you can disable error-preview sample page with set
['error-hero-module']['enable-error-preview-page']
to false.
Contributing
Contributions are very welcome. Please read CONTRIBUTING.md
All versions of error-hero-module with dependencies
laminas/laminas-db Version ^2.16.2
laminas/laminas-diactoros Version ^2.22
laminas/laminas-log Version ^2.16
laminas/laminas-mail Version ^2.21
laminas/laminas-psr7bridge Version ^1.8
laminas/laminas-uri Version ^2.10
psr/container Version ^1.1.2 || 2.0
samsonasik/array-lookup Version ^1.0
seld/jsonlint Version ^1.9
webmozart/assert Version ^1.11