mm-plazz / mezzio-monolog
Mezzio Monolog ErrorHandler
v1.0.0
2025-08-05 07:29 UTC
Requires
- php: >=8.2
- laminas/laminas-dependency-plugin: >=2.7
- laminas/laminas-servicemanager: >=4.4
- mezzio/mezzio: >=3.21
- monolog/monolog: >=3.9
Requires (Dev)
- phpstan/phpstan: >=2.1.22
- phpstan/phpstan-strict-rules: >=2.0.5
- sentry/sdk: >=4.0
- squizlabs/php_codesniffer: >=3.4
Suggests
- sentry/sdk: Allow sending log messages to Sentry.io
This package is auto-updated.
Last update: 2025-08-07 10:23:10 UTC
README
This library enables Monolog as ErrorHandler in Mezzio.
Currently, there are 2 handlers supported (more will be added if needed):
StreamHandler
: Logs records into any PHP stream, use this for log files.SentryHandler
: Logs records to Sentry.io (requiressentry/sdk
package).
Install
composer require mm-plazz/mezzio-monolog
Configuration
Create a monolog.global.php
file in your config
directory:
<?php declare(strict_types=1); return [ // StreamHandler 'stream' => [ 'path' => 'data/log/myapp.log', ], // SentryHanlder 'sentry' => [ 'dsn' => 'https://xxxxx@sentry.io/12345', ], ];
Usage
To enable it, you just have to add Plazz\Mezzio\Monolog\ConfigProvider::class
to your main configuration (usually config/config.php
):
...
$aggregator = new ConfigAggregator([
+ Plazz\Mezzio\Monolog\ConfigProvider::class,
...
], $cacheConfig['config_cache_path']);
...
The Monolog ErrorHandler will be active only in "production mode" (when $config['debug]
is false
).
To switch to "production mode", you can use composer run development-disable
.