liangguifeng / sentry
The sentry component for Hyperf.
v3.2.0-beta.1
2025-12-05 08:36 UTC
Requires
- hyperf/command: ~3.2.0
- hyperf/context: ~3.2.0
- hyperf/coroutine: ~3.2.0
- hyperf/di: ~3.2.0
- hyperf/event: ~3.2.0
- hyperf/exception-handler: ~3.2.0
- hyperf/framework: ~3.2.0
- hyperf/http-server: ~3.2.0
- hyperf/support: ~3.2.0
- hyperf/tappable: ~3.2.0
- sentry/sentry: ^4.19.0
- symfony/polyfill-php85: ^1.33
Suggests
- elasticsearch/elasticsearch: Required to use the elasticsearch client (^8.0 || ^9.0).
- hyperf/amqp: Required to use the amqp event (~3.2.0).
- hyperf/crontab: Required to use the crontab event (~3.2.0).
- hyperf/database: Required to use the crontab event (~3.2.0).
- hyperf/engine: Required to use the coroutine engine (^2.15.0).
- hyperf/rpc-multiplex: Required to use the rpc multiplex event (~3.2.0).
- phpmyadmin/sql-parser: Required to use the sql parser (^5.9).
This package is auto-updated.
Last update: 2026-05-23 06:45:35 UTC
README
The sentry component for Hyperf.
Installation
composer require friendsofhyperf/sentry
Publish Config File
php bin/hyperf.php vendor:publish friendsofhyperf/sentry
Enable Request Lifecycle
# config/autoload/server.php return [ // ... 'servers' => [ [ 'name' => 'http', 'type' => Server::SERVER_HTTP, 'host' => '0.0.0.0', 'port' => 9501, 'callbacks' => [ Event::ON_REQUEST => [Hyperf\HttpServer\Server::class, 'onRequest'], ], 'options' => [ 'enable_request_lifecycle' => true, ], ], ], // ... ];
Register Logger Handler
<?php return [ // ... 'sentry' => [ 'handler' => [ 'class' => FriendsOfHyperf\Sentry\SentryHandler::class, 'constructor' => [ 'level' => \Monolog\Logger::DEBUG, ], ], 'formatter' => [ 'class' => \Monolog\Formatter\LineFormatter::class, 'constructor' => [ 'format' => null, 'dateFormat' => null, 'allowInlineLineBreaks' => true, ] ], ], // ... ];
Annotation
<?php namespace App; use FriendsOfHyperf\Sentry\Annotation\Breadcrumb; class Foo { #[Breadcrumb(category: 'foo')] public function bar($a = 1, $b = 2) { return __METHOD__; } }
Trace
<?php # config/autoload/middleware.php return [ 'http' => [ FriendsOfHyperf\Sentry\Tracing\Middleware\TraceMiddleware::class => PHP_INT_MAX, ], // rpc // 'rpc' => [ // FriendsOfHyperf\Sentry\Tracing\Middleware\TraceMiddleware::class, // ], ];
Fix un-support native-curl
- Check
php --ri swoole |grep curl # curl-native => enabled
- Fix
composer require php-http/guzzle6-adapter # or composer require php-http/guzzle7-adapter
Sponsor
If you like this project, Buy me a cup of coffee. [ Alipay | WePay ]