synergitech / cronitor-laravel
Installs: 12 966
Dependents: 0
Suggesters: 1
Security: 0
Stars: 0
Watchers: 6
Forks: 0
Open Issues: 0
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
Install
composer require "synergitech/cronitor-laravel"
Version compatibility
- Laravel 6.x-8.x
- PHP 7.3-7.4, 8.0
Configuration
php artisan vendor:publish --provider="SynergiTech\Cronitor\Laravel\CronitorServiceProvider"
Usage
Automatically monitoring a Job
Your Jobs can be automatically monitored by this package by implementing the HasCronitorKey
contract.
use SynergiTech\Cronitor\Laravel\Contracts\HasCronitorKey; class YourJob implements HasCronitorKey { public function getMonitorKey(): string { return 'your monitor key from cronitor.io'; } }
When your Job is dispatched, a Dispatcher middleware will automatically send telemetry events based on whether your job is successful.
Monitoring arbitrary code
Additionally, you can monitor any callback via the Cronitor
facade:
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'); }); } }