PHP code example of cronpulse / laravel-monitor

1. Go to this page and download the library: Download cronpulse/laravel-monitor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

cronpulse / laravel-monitor example snippets


use Cronpulse\LaravelMonitor\Monitor;

$monitor = new Monitor();
$monitor->ping('start');

$monitor->ping('success');

$dynamicError = 'This is a dynamic error message';
$monitor->ping(['state' => 'fail', 'message' => $dynamicError]);

$monitor->ping('beat');

use function Cronpulse\LaravelMonitor\wrap;

wrap('your-job-key', function() {
    // Your job logic here
    return true;
});

wrap('your-job-key', function() {
    // Simulate job failure
    throw new \Exception('Something went wrong');
});
bash
php artisan vendor:publish --provider="Cronpulse\\LaravelMonitor\\MonitorServiceProvider"
bash
php artisan test