现在微服务Saas比较热门。那么微服务必然会选择Swoole。小编从零开始研究Swoole。
安装swoole
以mac操作系统为例,如果你是mac新手。
环境要求:php版本大于7.0
swoole php -v
PHP 7.1.19 (cli) (built: Jun 25 2018 10:42:21) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.19, Copyright (c) 1999-2018, by Zend Technologies
使用pecl
安装swoole,安装过程中,会提示你是否需要安装某些扩展,可自主选择yes或no,如果是选择安装redis扩展,本机需要安装redis环境
pecl install swoole
选择redis扩展需要先安装相应的库
brew install redis
brew install hiredis
ide自动提示
默认情况下,phpstorm
并不会自动提示swoole扩展包的相关函数,需要借助 swoole-ide-helper 实现自动提示
安装方法:
在项目的根目录执行:
composer require --dev "eaglewu/swoole-ide-helper:dev-master"
对于compoesr不熟悉的同学,自己可以从网上找点