windows phpStudy ThinkPHP 5.1 Workerman 快速上手指南

一、安装Workerman 

进入项目根目录运行命令(前提composer已经安装好)

官方教程:https://www.kancloud.cn/manual/thinkphp5_1/354134

composer require topthink/think-worker=2.0.*

windows phpStudy ThinkPHP 5.1 Workerman 快速上手指南_第1张图片

二、运行

安装完扩展后,你什么都不需要做,最简单的就是直接在命令行(应用根目录下面)下执行:

php think worker

windows phpStudy ThinkPHP 5.1 Workerman 快速上手指南_第2张图片

2.1  错误:错误原因:命名空间冲突 

[think\exception\ErrorException]
  Cannot use Workerman\Worker as Worker because the name is already in use

解决办法:

找到目录:
\vendor\topthink\think-worker\src\command\Server.php
 
找到命名空间:
use Workerman\Worker;
修改为:
use Workerman\Worker as Worker2;
紧接着修改 75,97,108, 119 行与 126的 worker 改为 Worker2
 
 
找到目录:
\vendor\topthink\think-worker\src\command\GatewayWorker.php
 
找到命名空间
use Workerman\Worker;
修改为:
use Workerman\Worker as Worker3;

windows phpStudy ThinkPHP 5.1 Workerman 快速上手指南_第3张图片

php think worker

windows phpStudy ThinkPHP 5.1 Workerman 快速上手指南_第4张图片

 

参考:

ThinkPHP 5.1 Workerman 快速上手指南:https://www.kancloud.cn/thinkphp/think-worker/722897

ThinkPHP 5.1 Workerman 快速上手指南:https://www.jianshu.com/p/5070b9f36654

windows下TP5 workerman的安装与简单demo:https://blog.csdn.net/weixin_40870531/article/details/87939580

你可能感兴趣的:(宝塔,thinkphp5,linux系统,thinkphp,php,Workerman)