PHP code example of misuoka / work-loop

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

    

misuoka / work-loop example snippets


# 假设文件:index.php 

;

$config = [
    'name'         => 'XXX服务后台业务程序', // 自定义项目名称
    'version'      => 'v1.0',              // 自定义项目版本
    'display_type' => 0, // UI形式。0:默认输出方式;1:重复刷新格式化的UI
    'workers' => [
        // 'workname' => [
        //     'enabled'      => true,  // 启用任务
        //     'logic'        => \app\logic\Xxxx::class, // 具体业务类,必须实现接口 misuoka\WorkLoop\WorkInterface
        //     'sleeptime'    => 0.3,   // 秒,支持小数。循环执行任务的休眠时间
        //     'working_time' => 10,    // 工作时长,单位分钟。进程循环执行的时间。时间到了之后,会再次启动进程
        // ],
    ],
];

$wd = new WorkGo($config);
$wd->run();
shell
# Usage: php script_name.php {start|restart|stop|help} [-d]
# -d 表示以守护进程的方式运行脚本
php script_name.php start