PHP code example of mattmezza / scheduled-job

1. Go to this page and download the library: Download mattmezza/scheduled-job 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/ */

    

mattmezza / scheduled-job example snippets


class MyTask extends TaskStandard {

    public function getDescriptionString(): string
    {
        return 'Task description';
    }

    public function run(array $allParam)
    {
        // do something
    }
}

class MyJob extends JobStandard {

    public function getDescriptionString(): string
    {
        return 'Job description';
    }

    public function getAllTask(): array
    {
        return [
            new MyTask(),
        ];
    }
}

(new JobExecutorStandard())->execute($job, $argv]);

$job->addObserver(new JobLogger());
$task->addObserver(new TaskLogger());

#!/usr/bin/env php



$job = ... # create the job as above

try {
    (new JobExecutorStandard())->execute($job, $argv]);
} catch (YourException $error) {
    // Oops, something happened...
}