nazirul-amin/sentinel-actor
Composer 安装命令:
composer require nazirul-amin/sentinel-actor
包简介
A Laravel package for monitoring applications by sending exception and event data to webhook endpoints with HMAC-SHA256 signature verification.
README 文档
README
This package provides a simple way to monitor your application by sending exception data to a webhook endpoint. It includes traits and utilities to automatically send exception information from jobs, notifications, and other parts of your application. Compatible with PHP 8.1+ and Laravel 10+.
Installation
You can install the package via composer (compatible with PHP 8.1+ and Laravel 10+):
composer require nazirul-amin/sentinel-actor
You can publish the config file with:
php artisan vendor:publish --tag="sentinel-actor-config"
This is the contents of the published config file:
return [ /* |-------------------------------------------------------------------------- | Monitoring Client Configuration |-------------------------------------------------------------------------- | | Here you can configure the monitoring client settings. | */ 'webhook' => [ 'url' => env('SENTINEL_WEBHOOK_URL'), 'endpoint' => env('SENTINEL_EXCEPTION_URL', '/application/exceptions'), 'status_endpoint' => env('SENTINEL_STATUS_URL', '/application/status'), 'application_id' => env('SENTINEL_APPLICATION_ID', 'app-id'), 'application_version' => env('SENTINEL_APPLICATION_VERSION', '1.0.0'), 'secret' => env('SENTINEL_WEBHOOK_SECRET'), ], 'enabled' => env('SENTINEL_ENABLED', true), 'levels' => [ 'info', 'success', 'warning', 'error', 'critical' ], ];
Configuration
Add the following environment variables to your .env file:
SENTINEL_WEBHOOK_URL=https://your-monitoring-service.com/webhook SENTINEL_EXCEPTION_URL=/application/exceptions SENTINEL_STATUS_URL=/application/status SENTINEL_APPLICATION_ID=your-app-name SENTINEL_APPLICATION_VERSION=1.0.0 SENTINEL_WEBHOOK_SECRET=your-hmac-secret SENTINEL_ENABLED=true
HMAC Signature Verification
This package supports HMAC signature verification for enhanced security. When you configure a secret in your .env file, all outgoing webhook requests will be signed with HMAC-SHA256.
The receiving service can verify the authenticity of the request by comparing the signature in the Sentinel-Signature header with a locally computed signature using the same secret.
Usage
Monitoring Exceptions in Jobs
To automatically send exception data from your jobs, simply use the MonitorsExceptions trait:
<?php namespace App\Jobs; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use NazirulAmin\SentinelActor\Traits\MonitorsExceptions; use Throwable; class YourJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, MonitorsExceptions; // Your job properties and methods public function handle() { // Your job logic here } // Optional: Add context data to be sent with exception protected function getMonitoringContextData(): array { return [ 'job_specific_data' => $this->someProperty, ]; } }
Monitoring Exceptions in Notifications
Similarly, you can monitor exceptions in notifications:
<?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Notification; use NazirulAmin\SentinelActor\Traits\MonitorsExceptions; class YourNotification extends Notification implements ShouldQueue { use Queueable, MonitorsExceptions; // Your notification properties and methods public function via($notifiable) { return ['mail']; } public function toMail($notifiable) { // Your notification logic here } // Optional: Add context data to be sent with exception protected function getMonitoringContextData(): array { return [ 'notification_specific_data' => $this->someProperty, ]; } }
Application Health Status Monitoring
To send application health status updates (active/inactive), use the UpdatesApplicationStatus trait:
<?php namespace App\Services; use NazirulAmin\SentinelActor\Traits\UpdatesApplicationStatus; class HealthCheckService { use UpdatesApplicationStatus; public function checkHealth() { try { // Perform health checks $isHealthy = $this->performHealthChecks(); // Send health status $this->updateHealthStatus($isHealthy, $isHealthy ? 'Application is healthy' : 'Application is unhealthy', [ 'checked_at' => now()->toISOString(), 'environment' => app()->environment(), ]); } catch (Exception $e) { // Send unhealthy status on error $this->updateHealthStatus(false, 'Health check failed: ' . $e->getMessage()); } } private function performHealthChecks(): bool { // Implement your health checks here // Return true if healthy, false if unhealthy return true; } // Optional: Add context data to be sent with status updates protected function getStatusContextData(): array { return [ 'service_specific_data' => $this->someProperty, ]; } }
Scheduled Health Checks
The package includes a built-in health check command that can be scheduled to run periodically:
// In your App\Console\Kernel class protected function schedule(Schedule $schedule) { $schedule->command('sentinel:health-check') ->everyMinute() ->withoutOverlapping(); }
This command performs basic health checks and sends the status to your monitoring service. You can customize the health checks by extending the command.
Manual Exception Monitoring
You can also manually send exception data using the facade:
use NazirulAmin\SentinelActor\Facades\SentinelActor; use Throwable; try { // Some code that might throw an exception } catch (Throwable $exception) { SentinelActor::sendException($exception, [ 'additional_context' => 'some_value', ]); }
Sending Custom Events
You can also send custom events to your monitoring service:
use NazirulAmin\SentinelActor\Facades\SentinelActor; SentinelActor::send('/application/events', [ 'application_id' => 'your-app-name', 'application_version' => '1.0.0', // Automatically added by the package 'environment' => 'production', // Automatically added by the package 'event_type' => 'user_registered', 'level' => 'info', 'message' => 'A new user registered', 'context' => [ 'user_id' => 123, ], 'timestamp' => time(), ]);
Webhook Payload Structure
All webhooks sent by this package include the following data:
Exception Webhooks
application_id: The application identifier from configapplication_version: The application version from configenvironment: The current Laravel environment (local, production, staging, etc.)type: Set to 'exception'message: The exception messagefile: The file where the exception occurredline: The line number where the exception occurredtimestamp: Unix timestamp when the exception occurredcode: The exception codetrace: The full exception tracecontext: Additional context information
Health Status Webhooks
application_id: The application identifier from configapplication_version: The application version from configenvironment: The current Laravel environment (local, production, staging, etc.)type: Set to 'health_status'status: Either 'active' or 'inactive'healthy: Boolean value indicating health status (true/false)message: Optional message describing the health statustimestamp: Unix timestamp when the health status was sentcontext: Additional context information
Status Update Webhooks (Legacy)
application_id: The application identifier from configapplication_version: The application version from configenvironment: The current Laravel environment (local, production, staging, etc.)type: Set to 'status_update'status: The status being reported (e.g., 'running', 'stopped', 'maintenance')message: Optional message describing the statustimestamp: Unix timestamp when the status update was sentcontext: Additional context information
All requests are signed with HMAC-SHA256 for security.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
nazirul-amin/sentinel-actor 适用场景与选型建议
nazirul-amin/sentinel-actor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 09 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「nazirulamin」 「sentinel-actor」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nazirul-amin/sentinel-actor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nazirul-amin/sentinel-actor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nazirul-amin/sentinel-actor 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alfabank REST API integration
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
Boot a Laravel project on any machine with one command: app:serve installs missing tools (PHP, Node, Composer, Herd, Docker), creates .env, sets up the database, runs migrations, builds assets, starts a queue worker and serves via Herd, Sail or artisan serve; app:down cleanly stops everything it sta
Branded, diagnostic error pages (500, 403, 404, 419, 503) for Filament — native Filament UI, dark mode and translations out of the box.
Turn any PDF into a Pingen-ready A4 letter (generated address cover page + A4 normalisation + safe margins) and send it through the Pingen print & mail API. Laravel-first.
统计信息
- 总下载量: 35
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-12