1. Go to this page and download the library: Download cronitor/cronitor-php 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/ */
cronitor / cronitor-php example snippets
$cronitor = new Cronitor\Client('api_key_123');
$closureVar = time();
$cronitor->job('weekly-report-job', function() use ($closureVar){
new WeeklyReportJob($closureVar)->run();
});
$cronitor = new Cronitor\Client('api_key_123');
$monitor = $cronitor->monitor('heartbeat-monitor');
$monitor->ping(); # a basic heartbeat event
# optional params can be passed as kwargs
# complete list - https://cronitor.io/docs/telemetry-api#parameters
$monitor->ping(['state' => 'run']); # a job/process has started
# a job/process has completed (
# read config file and set credentials (if
# sync config file's monitors to Cronitor.
$cronitor->applyConfig();
# send config file's monitors to Cronitor to validate correctness.
# monitors will not be saved.
$cronitor->validateConfig();
# save config to local YAML file (defaults to cronitor.yaml)
$cronitor->generateConfig();
$monitor = $cronitor->monitor('heartbeat-monitor');
$monitor->pause(24) # pause alerting for 24 hours
$monitor->unpause() # alias for ->pause(0)
$monitor->ok() # manually reset to a passing state alias for $monitor->ping({state: ok})
$monitor->delete() # destroy the monitor