1. Go to this page and download the library: Download yiisoft/yii-sentry library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yiisoft / yii-sentry example snippets
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\ClientInterface;
use Http\Adapter\Guzzle7\Client as GuzzleClientAdapter;
use Http\Client\HttpAsyncClient;
use HttpSoft\Message\RequestFactory;
use HttpSoft\Message\ResponseFactory;
use HttpSoft\Message\StreamFactory;
use HttpSoft\Message\UriFactory;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Yiisoft\Definitions\Reference;
return [
// HTTP Factories
StreamFactoryInterface::class => StreamFactory::class,
RequestFactoryInterface::class => RequestFactory::class,
LoggerInterface::class => NullLogger::class,
UriFactoryInterface::class => UriFactory::class,
ResponseFactoryInterface::class => ResponseFactory::class,
// HTTP Client
HttpClient::class => GuzzleClient::class,
HttpAsyncClient::class => [
'class' => GuzzleClientAdapter::class,
'__construct()' => [
Reference::to(ClientInterface::class),
],
],
];
return [
// ...
'middlewares' => [
ErrorCatcher::class,
SentryMiddleware::class, // <-- here
SessionMiddleware::class,
CookieMiddleware::class,
CookieLoginMiddleware::class,
LocaleMiddleware::class,
Router::class,
],
// ...
'yiisoft/yii-sentry' => [
'handleConsoleErrors' => false, // Add to disable console errors.
'options' => [
// Set to `null` to disable error sending (note that in case of web application errors it only prevents
// sending them via HTTP). To disable interactions with Sentry SDK completely, remove middleware and the
// rest of the config.
'dsn' => $_ENV['SENTRY_DSN'] ?? null,
'environment' => $_ENV['YII_ENV'] ?? null, // Add to separate "production" / "staging" environment errors.
],
],
// ...
]