PHP code example of honchoagency / craft-deadman

1. Go to this page and download the library: Download honchoagency/craft-deadman 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/ */

    

honchoagency / craft-deadman example snippets




namespace modules\mysite\deadman;

use honchoagency\deadman\checks\CheckInterface;
use honchoagency\deadman\models\CheckResult;

class ImportFreshnessCheck implements CheckInterface
{
    public function run(array $params): CheckResult
    {
        $isFresh = /* your own logic here, using $params */ true;

        return $isFresh
            ? CheckResult::pass('Import is up to date.')
            : CheckResult::fail('Import looks stale.');
    }
}

'importFreshness' => [
    'type' => \modules\mysite\deadman\ImportFreshnessCheck::class,
    'params' => ['maxAgeHours' => 26],
    'successUrl' => getenv('DEADMAN_IMPORT_URL'),
],

'cpAlertUrl' => 'utilities/queue-manager', // a CP-relative path, or a full URL
'cpAlertLabel' => 'Go to Queue Manager',

'cpAlertMessage' => function (CheckResult $result): string {
    // $result is reconstructed from the check's last recorded outcome, not a
    // fresh run — treat it as historical, potentially stale-by-seconds data.
    return "There have been no Formie submissions recently ({$result->message})";
},
sh
cp vendor/honchoagency/craft-deadman/src/config.php config/deadman.php
bash
# Push 5 jobs (default)
php craft deadman/test/seed-jobs

# Push 20, each delayed 30s before becoming eligible for pickup
php craft deadman/test/seed-jobs --count=20 --delay=30