我正在尝试在我们的应用程序中实现 Sentry。
我已经使用了 sentry/sdk
,但出现了一些错误(可能是由于某些 PHP 设置),所以我现在正在尝试切换 transport method。
我从我的 composer.json 文件中删除了 sentry/sdk
,并将其替换为 sentry/sentry
和 php-http/guzzle7-adapter
。请注意,在文档中,他们使用了 guzzle6-adapter
,但这会导致依赖性错误(我已经在使用 "guzzlehttp/guzzle": "^7.3"
,因此我需要使用版本 7)。
现在尝试初始化 Sentry 时,出现以下错误:
Fatal error: Uncaught Http\Discovery\Exception\DiscoveryFailedException: Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors - Puli Factory is not available - No valid candidate found using strategy "Http\Discovery\Strategy\CommonClassesStrategy". We tested the following candidates: . - No valid candidate found using strategy "Http\Discovery\Strategy\CommonPsr17ClassesStrategy". We tested the following candidates: Phalcon\Http\Message\StreamFactory, Nyholm\Psr7\Factory\Psr17Factory, Zend\Diactoros\StreamFactory, GuzzleHttp\Psr7\HttpFactory, Http\Factory\Diactoros\StreamFactory, Http\Factory\Guzzle\StreamFactory, Http\Factory\Slim\StreamFactory, Laminas\Diactoros\StreamFactory, Slim\Psr7\Factory\StreamFactory. in vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php:41
这是一个自定义应用程序,所以我不能使用例如Sentry Laravel 包。
答案 0 :(得分:0)
目前文档不正确,引用了所需的旧依赖项。
如果您想使用 Guzzle,请执行以下操作:
composer require sentry/sentry guzzlehttp/guzzle http-interop/http-factory-guzzle
这将重新创建当前的 SDK 元数据包 dependencies:
"require": {
"sentry/sentry": "^3.1",
"http-interop/http-factory-guzzle": "^1.0",
"symfony/http-client": "^4.3|^5.0"
},
除了 symfony/http-client
被 guzzlehttp/guzzle
替换。