https://github.com/synergitech/cronitor-laravel
https://github.com/synergitech/cronitor-laravel
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/synergitech/cronitor-laravel
- Owner: SynergiTech
- License: mit
- Created: 2021-04-26T15:42:14.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-09-19T10:55:33.000Z (over 1 year ago)
- Last Synced: 2025-08-30T14:52:53.661Z (10 months ago)
- Language: PHP
- Size: 31.3 KB
- Stars: 0
- Watchers: 5
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cronitor-laravel
[](https://github.com/SynergiTech/cronitor-laravel/actions/workflows/tests.yaml)
## Install
```sh
composer require "synergitech/cronitor-laravel"
```
### Version compatibility
* Laravel 6.x-8.x
* PHP 7.3-7.4, 8.0
### Configuration
```sh
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.
```php
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:
```php
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');
});
}
}
```