推荐学习: swoole视频教程
最新的swoole-cli已支持 windows 环境,基于cygwin64实现,下载即可使用。
下载一台新装的windows机器(必须为64位系统)无需安装任何php相关的软件包,可直接下载swoole-cli-cygwin64的可执行程序zip压缩包,然后解压到任意一个目录即可。
swoole-cli是免安装的,可直接使用
下载地址:https://github.com/swoole/swoole-src/releases/download/v4.8.7/swoole-cli-v4.8.7-cygwin64.zip
swoole-cli会跟随swoole同步发布,可在github release页面下载到最新版本的swoole-cli
使用首先需要将解压后的文件夹/bin目录配置到系统的path环境变量中。
使用win+r输入cmd进入windows命令行,可使用swoole-cli命令执行swoole或者php的程序。
扩展swoole-cli包含了常用的各类扩展,列表如下:
如果您希望增加扩展到swoole-cli,可以在swoole官方的github主页提交issue
swoole-cli使用的php版本为8.1.1
d:\>swoole-cli -m[php modules]bcmathbz2corectypecurldatedomexiffileinfofiltergdgmphashiconvimagickjsonlibxmlmbstringmysqlimysqlndopensslpcrepdopdo_mysqlpdo_sqlitepharposixredisreflectionsessionsimplexmlsoapsocketssodiumsplsqlite3standardswooletokenizerxmlxmlreaderxmlwriterxslyamlzipzlib[zend modules]
启动 web 服务器编写一个最简单的web服务进行测试,文件名为server.php:
<?php$http = new swoole\http\server('127.0.0.1', 9501, swoole_base);$http->on('start', function ($server) { echo "swoole http server is started at http://127.0.0.1:9501\n";});$http->on('request', function ($request, $response) { $response->header('content-type', 'text/plain'); $response->end('hello world');});$http->start();
运行:
打开浏览器,输入http://127.0.0.1:9501/可以看到结果。
推荐学习: swoole教程
以上就是最新的swoole-cli能支持windows环境了!的详细内容。
