- 安装workman
-
composer require topthink/think-worker
-
- 创建command
-
php think make:command Hello hello
-
- 修改config/console.php
-
return [ 'commands' => [ 'hello' => 'app\command\Hello', ] ];
-
- 代码
-
<?php namespace app\command; use think\console\Command; use think\console\Input; use think\console\input\Argument; use think\console\input\Option; use think\console\Output; use Workerman\Worker; class Hello extends Command { protected $timer; protected function configure() { $this->setName('hello') ->addArgument('status', Argument::REQUIRED, 'start/stop/reload/status/connections') ->addOption(&#
-
tp6使用workman实现定时任务
于 2022-10-20 09:27:00 首次发布
本文介绍了如何在ThinkPHP6(TP6)框架下利用Workerman进行定时任务的设置。首先,讲述了如何安装Workerman,然后详细说明了创建Command的过程,接着修改了config/console.php配置文件以配合定时任务。最后,给出了运行命令`php think hello start --d`以启动定时任务。
摘要由CSDN通过智能技术生成