1. Go to this page and download the library: Download hellocron/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/ */
hellocron / php example snippets
use HelloCron\HelloCron;
$cx = new HelloCron(ingestKey: 'ck_your_key');
$cx->job('db-backup', function () {
// ... do the work ...
});
use HelloCron\HelloCron;
use HelloCron\Enum\PingStatus;
$cx = new HelloCron(ingestKey: 'ck_your_key');
$series = uniqid();
$cx->ping('db-backup', PingStatus::Run, series: $series);
// ... do the work ...
$cx->ping('db-backup', PingStatus::Complete, series: $series, duration: 47.3, exitCode: 0);
// derives expected_interval_seconds from the schedule and a grace of
// interval/2 clamped to [2 min, 1 h]; needs dragonmantank/cron-expression
$cx->monitors()->ensure('db-backup', cronExpression: '0 3 * * *');
// or state the interval yourself - no extra package needed
$cx->monitors()->ensure('db-backup', intervalSeconds: 86400);
// computed fields can be overridden
$cx->monitors()->ensure('db-backup', intervalSeconds: 86400, extra: ['tags' => ['production']]);
// validate the file in CI (no changes are made)
$report = $cx->monitors()->applyFromFile('monitors.yaml', dryRun: true);
// apply it on deploy
$report = $cx->monitors()->applyFromFile('monitors.yaml');
// snapshot the current account state back into a file
$cx->monitors()->exportToFile('monitors.yaml');
use HelloCron\Enum\ErrorCode;
use HelloCron\Exception\{ValidationException, AuthException, RateLimitException,
ConfirmRequiredException, ConfigAsCodeDisabledException, TransportException};
try {
$cx->monitors()->create($manifest);
} catch (ValidationException $e) {
// $e->errorCodes() => ['schedule' => [ErrorCode::ScheduleInvalid]]
// $e->errors() => human-readable messages per field
} catch (AuthException $e) {
// bad key, or a scoped key missing the needed scope
} catch (RateLimitException $e) {
// 60 req/min per management key
}
$cx = new HelloCron(
ingestKey: 'ck_your_key',
httpClient: new \GuzzleHttp\Client(['connect_timeout' => 1, 'timeout' => 2]),
);
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.