thinkphp6利用workerman实现定时任务
2022-11-24 11:10:29
150
{{single.collect_count}}

1.根据官方文档安装好workerman,配置好tp6配置文件
2.贴执行文件代码

<?phpnamespace app\http;use think\worker\Server;use Workerman\Lib\Timer;class Haha extends Server{//写一个假的监听地址protected $socket = 'http://127.0.0.1:2347';/** * 每个进程启动 * @param $worker */public function onWorkerStart(){//定时任务Timer::add(1, function () {echo "哈哈";});}}
回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}