安装composer1.8.5
我这里用的是phpStudy作为示例,在网站管理这里设置composer
点击确定后弹出窗体
这时候默认的是进入thinkphp项目的public目录,所以我们要出来,输入cd..
开始安装:
composer require topthink/think-worker
此时会弹出一个问题:
D:\phpstudy_pro\WWW\XXX>composer require topthink/think-worker
Warning from https://mirrors.aliyun.com/composer: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Using version ^3.0 for topthink/think-worker
./composer.json has been updated
Loading composer repositories with package information
Warning from https://mirrors.aliyun.com/composer: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
意思就是composer版本较低,至少需要升级到2.0,看到这个问题,我们可以终止安装,但我这里感觉只是警告,就没有过多的操作,如果对这个警告看不下去,就直接手动安装2.0,记得composer的目录指向phpstudy对应composer目录
没有过多的瘸着,到这里大概率是成功了
php think worker
这时候我们去访问以下这个地址,是能够正常访问我们的应用的
http://localhost:2346
不过有不少朋友出现类似的问题:
Too few arguments to function think\worker\Cookie::saveCookie(), 7 passed in D:\phpstudy_pro\WWW\XXX\vendor\topthink\framework\src\think\Cookie.php on line 186 and exactly 8 expected
这是因为Cookie.php的参数部分没有给默认值
将string samesite改成string samesite=""即可,同时按Ctrl+C终止并重新启动worker即可