mileschou / monoex
Monolog 扩展
v2.1.1
2023-10-11 02:17 UTC
Requires
- php: ^8.1
- ext-json: *
- monolog/monolog: ^3
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
- psr/log: ^2.0 || ^3.0
Requires (Dev)
- laminas/laminas-diactoros: ^2.2
- laravel/framework: ^10
- mileschou/psr: ^1.1
- phpunit/phpunit: ^10
- squizlabs/php_codesniffer: ^3.7
Suggests
- laminas/laminas-diactoros: Require ^2 if need use PSR-17 HTTP factory
- symfony/http-client: Require ^4.4 | ^5 if need use PSR-18 HTTP client
README
Monolog 扩展。
- 版本 0.x 支持 PHP 7.1 ~ 8.0 和 Laravel 5.7 ~ 9.0。
- 版本 2.x 支持 PHP 8.1 和 Laravel 10。
在 Laravel 上使用
此包实现了包发现,以下PSR-17 / PSR-18 驱动必须注册
Psr\Http\Client\ClientInterface
Psr\Http\Message\RequestFactoryInterface
Psr\Http\Message\StreamFactoryInterface
例如,使用laminas/laminas-diactoros
和 symfony/http-client
$app->singleton(RequestFactoryInterface::class, new \Laminas\Diactoros\RequestFactory()); $app->singleton(ResponseFactoryInterface::class, new \Laminas\Diactoros\ResponseFactory()); $app->singleton(StreamFactoryInterface::class, new \Laminas\Diactoros\StreamFactory()); $app->singleton(ClientInterface::class, function($app) { return new \Symfony\Component\HttpClient\Psr18Client( null, $app->make(ResponseFactoryInterface::class), $app->make(StreamFactoryInterface::class) ); });
最后,可以在 logging.php
配置中使用新的驱动 psr18slack
return [ 'channels' => [ 'stack' => [ 'driver' => 'psr18slack', // same as slack driver 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'username' => 'Laravel Log', 'emoji' => ':boom:', 'level' => 'critical', ], ], ];
许可证
MIT 许可证 (MIT)。请参阅许可证文件获取更多信息。