PHP code example of phalapi / task

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

    

phalapi / task example snippets


    /**
     * 计划任务配置
     */
    'Task' => array(
        //MQ队列设置,可根据使用需要配置
        'mq' => array(
            // 默认使用文件MQ
            'file' => array(
                'path' => API_ROOT . '/runtime',
                'prefix' => 'phalapi_task',
            ),
        ),
    ),


/**
 * 计划任务入口示例
 * ./bin/crontab.php 文件
 */
un();
} catch (Exception $ex) {
    echo $ex->getMessage();
    echo "\n\n";
    echo $ex->getTraceAsString();
    // notify ...
}
./bin/crontab.php
bash
$ php ./bin/crontab.php
bash
# PhalApi-Task计划任务
*/1 * * * * php /path/to/phalapi-pro/bin/crontab.php > /dev/null
bash
# PhalApi-Task计划任务
*/1 * * * * php /path/to/phalapi-pro/bin/crontab.php >> /path/to/phalapi-pro/runtime/crontab.log 2>&1