… 站点 www.apijs.cc 是使用 CI3框架来写的,并且提供了一些的免费API。后来我发现了个好东西 swoole,为了性能,所以我就用它来重构了免费API的项目。
由于这一段时间以来,接触到了PHP 常驻内存的功能,发现它非常有优势,所以打算往这一块发展了,毕竟往后的趋势都是往物联网方向发展的了。
PHP方面有两个比较优秀的东西:workerman 和 swoole,知乎上有人写了很详细的对比,具体优劣我就不多说了。
基于 swoole 的框架有很多,并且都非常棒,swoft 框架是我比较推荐的,是基于 swoole 2.x 的,并且文档也比较详细,所以我就选择了它。
环境搭建的过程中,踩过一些坑。
现在来记录一下:
以下所有命令均为 root 权限下:
首先安装 swoole:
使用
1 |
pecl install swoole |
swoft 框架需要安装 hiredis:
网址:https://github.com/redis/hiredis/releases
1 2 3 |
wget https://github.com/redis/hiredis/archive/v0.13.3.tar.gz tar -zxvf v0.13.3.tar.gz cd hiredis-0.13.3/ |
安装 hiredis:
1 2 3 |
make -j make install ldconfig |
需要将 proc_open,proc_get_status 启用
1 |
disable_functions: proc_open,proc_get_status (移除这两个) |
安装 swoft:
Composer 方式安装
1 |
composer create-project swoft/swoft swoft dev-master |
或者手动 clone 项目: https://github.com/swoft-cloud/swoft
安装依赖:
1 |
composer install |
执行程序:
1 |
php bin/swoft start |
API 集市的免费 API 项目,以后
转载请注明:SKIY开发笔记 » 使用 swoole 之 swoft 框架