介绍swoft中
1、Task
2、协程
一:Task任务:
1、配置,在 app/bean.php文件中加入
'httpServer' => [
// ...
'on' => [
SwooleEvent::TASK => \bean(TaskListener::class), // Enable task must task and finish event
SwooleEvent::FINISH => \bean(FinishListener::class)
],
/* @see HttpServer::$setting */
'setting' => [
'task_worker_num' => 12,
'task_enable_coroutine' => true,
'worker_num' => 2
]
],
View Code
2、定时任务
1、安装 composer require swoft/crontab
2、配置
'httpServer' => [
// ...
'process' => [
'crontab' => bean