PHP code example of guanhui07 / dcr-swoole-crontab

1. Go to this page and download the library: Download guanhui07/dcr-swoole-crontab 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/ */

    

guanhui07 / dcr-swoole-crontab example snippets


return [
...
    'listem' => [
        ...
        'swoole.init' => [
            ...
            \DcrSwooleCrontab\Process\CrontabDispatcherProcess::class,
            ...
        ],
        ...
    ],
...
];

或 在启动脚本加
$crontab = new CrontabDispatcherProcess();
$crontab->handle();





return [
    'crontab' => [
        (new \DcrSwooleCrontab\Crontab())->setName('test-1')
            ->setRule('* * * * * *')
            ->setCallback([Test::class, 'run'])
            ->setMemo('just a test crontab'),
        (new \DcrSwooleCrontab\Crontab())->setName('test-2')
            ->setRule('* * * * * *')
            ->setCallback([Test::class, 'run'])
            ->setMemo('just another test crontab'),
    ],
];