1. 首先通过 composer 安装,切换到项目根目录,输入命令

composer require topthink/think-worker

如果遇见错误:

1
2
3
4
5
Using version ^6.3 for guzzlehttp/guzzle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

解决办法:在composer.json中添加以下
“minimum-stability”: “dev”, //这个遇上require时完全可以用上

  1. 如果需要在window下做服务端,还需要

composer require workerman/workerman-for-win

首先要明白composer之后workerman是安装到哪去了,安装到tp5项目下vendor目录中

运行出现错误PHP Fatal error: Call to undefined function Workerman\Lib\pcntl_signal(),需要删除vendor\workerman\workerman,防止命名覆盖

参考:https://www.100txy.com/index.php/article/139.html
常见错误解决方法:https://blog.csdn.net/qq_32642039/article/details/78292685
composer 安装速度太慢:https://packagist.laravel-china.org/