这框架是Swoole成员开发的,据说比Swoole性能高。
我的系统 Centos 7, 宝塔面板, php7.2 已经安装 redis扩展和Swoole扩展。
1 先升级下composer /usr/bin/composer self-update
composer安装,任意目录即可运行,不依赖于apache或nginx等服务器。
2 切换阿里云composer镜像
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
3 php7.2的函数proc_open exec putenv pcntl_fork 可能在禁用函数的名单里,请先移除。
4 执行 composer create-project hyperf/hyperf-skeleton
安装过程出现几个选项 mysql和redis选y其他全部先n
What time zone do you want to setup ?
[n] Default time zone for php.ini
Make your selection or type a time zone name, like Asia/Shanghai (n):
n
Do you want to use Database (MySQL Client) ?
[y] yes
[n] None of the above
Make your selection or type a composer package name and version (yes): y
- Adding package hyperf/database (~2.0.0)
- Adding package hyperf/db-connection (~2.0.0)
去php.ini 关闭swoole短名称 swoole.use_shortname = 'Off'
启动
php hyperf.php start
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\Config\Listener\RegisterPropertyHandlerListener listener.
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\ExceptionHandler\Listener\ExceptionHandlerListener listener.
[DEBUG] Event Hyperf\Framework\Event\BootApplication handled by Hyperf\DbConnection\Listener\RegisterConnectionResolverListener listener.
[DEBUG] Event Hyperf\Framework\Event\BeforeMainServerStart handled by Hyperf\Process\Listener\BootProcessListener listener.
[DEBUG] Event Hyperf\Framework\Event\OnStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[DEBUG] Event Hyperf\Framework\Event\OnManagerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[INFO] Worker#0 started.
[INFO] Worker#1 started.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\AfterWorkerStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
[INFO] HTTP Server listening at 0.0.0.0:9501
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\AfterWorkerStartListener listener.
[DEBUG] Event Hyperf\Framework\Event\AfterWorkerStart handled by Hyperf\Server\Listener\InitProcessTitleListener listener.
这样就是安装完成了。
新开一个ssh窗口
curl 0.0.0.0:9501
返回 {"method":"GET","message":"Hello Hyperf."}
执行成功。
//php bin/hyperf.php start