Redis配合ThinkPHP(tp6.0.8)实现消息队列
运行环境
Windows 10
本地环境
PHP 7.2.9
ThinkPHP v6.0.8
Redis v3.2.100
安装
tp6.0只能通过composer方式安装,而且默认框架不带ORM和Queue,都需要通过composer方式安装。tp6.0环境默认安装的是最新版think-queue,目前是3.X版本。composer require topthink/think-queue
注意:如果是tp5.1,只能安装2.X版本,命令为:composer require topthink/think-queue=2.*
验证是否安装成功,只需命令行执行:php think queue:listen -h
,看到如下画面,说明安装成功。
配置
安装成功之后,在config
目录下会有一个queue.php
文件,我们选择redis
驱动类型,默认驱动类型是sync
,即同步执行。