php-bug-catcher / bug-catcher-reporter-bundle
一个用于向Bug Catcher报告异常的Symfony组件
v2.0.2
2024-09-04 16:16 UTC
Requires
- php: >=8.1
- kregel/exception-probe: ^1.0
- monolog/monolog: ^3.0
- symfony/dependency-injection: ^5.4|^6.4|^7.0
- symfony/event-dispatcher: ^6.4
- symfony/framework-bundle: ^5.4|^6.4|^7.0
- symfony/monolog-bundle: ^3.10
Requires (Dev)
- doctrine/common: ^3.4
- phpunit/phpunit: ^9.5
- symfony/dotenv: ^5.4|^6.4|^7.0
- symfony/http-client: ^5.4|^6.4|^7.0
- symfony/orm-pack: ^2.4
- symfony/phpunit-bridge: ^5.4|^6.4|^7.0
- symfony/yaml: ^5.4|^6.4|^7.0
README
捕获您的Symfony应用程序中的每一个错误
安装
请确保已全局安装Composer,具体请参考Composer文档中的安装章节。
使用Symfony Flex的应用程序
打开命令行控制台,进入您的项目目录,并执行以下命令:
$ composer require php-sentinel/reporter-bundle
versions
不使用Symfony Flex的应用程序
步骤 1:下载组件
打开命令行控制台,进入您的项目目录,并执行以下命令下载此组件的最新稳定版本:
$ composer require php-sentinel/bug-catcher-reporter-bundle
步骤 2:启用组件
然后,通过将其添加到项目 config/bundles.php
文件中注册的组件列表来启用该组件。
// config/bundles.php return [ BugCatcher\Reporter\BugCatcherReporterBundle::class => ['all' => true], ];
配置
如果您想通过HTTP请求发送捕获的错误
composer require symfony/http-client
# config/packages/bug_catcher.yaml services: app.chain_uri_catcher: class: BugCatcher\Reporter\UrlCatcher\ChainUriCatcher arguments: $uriCatchers: - '@bug_catcher.uri_catcher.http_catcher' - '@bug_catcher.uri_catcher.console_catcher' framework: http_client: scoped_clients: # only requests matching scope will use these options bug_catcher.client: base_uri: 'https://your-bug-catcher-instance:8000' bug_catcher: project: 'dev' http_client: 'bug_catcher.client' uri_cather: 'app.chain_uri_catcher'
由Monolog自动记录
composer require symfony/monolog-bundle
# config/packages/monolog.yaml monolog: handlers: bug_catcher: type: service id: bug_catcher.handler level: 500
自定义记录
class Foo { public function __construct(private readonly BugCatcherInterface $bugCatcher) { } public function foo():void { $this->bugCatcher->log([ "message" => "My message", "level" => 500, "projectCode" => "dev", "requestUri" => "my uri", ]); $this->bugCatcher->logRecord("My log record", 500); $this->bugCatcher->logException(new \Exception("My Exception")); } }