synergitech / cronitor-laravel
v1.0.0
2024-09-19 10:54 UTC
Requires
- illuminate/contracts: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
- synergitech/cronitor: ^0.0.1
Requires (Dev)
- larastan/larastan: ^2.9
- orchestra/testbench: ^7.0|^8.0|^9.0
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.1
- phpunit/phpunit: ^9.5|^10.0
- symplify/easy-coding-standard: ^9.2
README
安装
composer require "synergitech/cronitor-laravel"
版本兼容性
- Laravel 6.x-8.x
- PHP 7.3-7.4, 8.0
配置
php artisan vendor:publish --provider="SynergiTech\Cronitor\Laravel\CronitorServiceProvider"
使用方法
自动监控作业
通过实现 HasCronitorKey
接口,此包可以自动监控您的作业。
use SynergiTech\Cronitor\Laravel\Contracts\HasCronitorKey; class YourJob implements HasCronitorKey { public function getMonitorKey(): string { return 'your monitor key from cronitor.io'; } }
当您的作业被调度时,一个调度器中间件会根据作业是否成功自动发送遥测事件。
监控任意代码
此外,您还可以通过 Cronitor
门面监控任何回调。
use SynergiTech\Cronitor\Laravel\Facades\Cronitor; class YourClass { public function handle() { Cronitor::monitorJob('your monitor key', function () { throw new \Exception('This will automatically be reported as a fail event'); }); } }