1. Go to this page and download the library: Download cltv/yii3sentry 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-cycle' => [
// DBAL config
'dbal' => [
// SQL query logger. Definition of Psr\Log\LoggerInterface
// For example, \Yiisoft\Yii\Cycle\Logger\StdoutQueryLogger::class
'query-logger' => \Webvork\Yii3\Sentry\DbLoggerDecorator::class,
/**
* ...
* your another db settings
**/
]
]
'middlewares' => [
ErrorCatcher::class,
Webvork\Yii3\Sentry\Http\SetRequestIpMiddleware::class, //add this
Router::class,
],
RouteCollectionInterface::class => static function (RouteCollectorInterface $collector) use ($config) {
$collector
->middleware(FormatDataResponse::class)
->middleware(JsonParseMiddleware::class)
->middleware(ExceptionMiddleware::class)
->middleware(\Webvork\Yii3\Sentry\Tracing\SentryTraceMiddleware::class) // add this
->addGroup(
Group::create('')
->routes(...$config->get('routes'))
);
return new RouteCollection($collector);
},
GuzzleHttp\Client::class => static function (ContainerInterface $container) {
$stack = new HandlerStack();
$stack->setHandler(new CurlHandler());
$factory = $container->get(GuzzleMiddlewareFactory::class);
$middleware = static function (callable $handler) use ($factory): callable {
return $factory->factory($handler);
};
$stack->push($middleware);
return new GuzzleHttp\Client([
'handler' => $stack,
]);
},
/** some code with default transaction */
/** commit default transaction and send data to sentry server */
$sentryTraceString = $this->sentryTransactionAdapter->commit();
while ($currentDate <= $endDate) {
$this->sentryTransactionAdapter->begin($sentryTraceString)
->setName('my_heavy_operation/iteration')
->setData(['date' => $currentDate->format('Y-m-d')]);
$this->process($currentDate, $sentryTraceString);
$this->sentryTransactionAdapter->commit();
}
$this->sentryTransactionAdapter->begin($sentryTraceString)
->setName('my_heavy_operation done, terminating application');
/** transaction will commit when application is terminated */
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.