PHP微服务:搭建Hyperf

本文介绍了如何在宝塔环境下为Hyperf 2.2版本安装PHP 7.4,移除禁用函数,并配置Redis和Swoole 4,同时详细步骤包括手动安装pcntl扩展和Composer创建及初始化项目。遇到Swoole短函数名问题时,提供了解决方法。
摘要由CSDN通过智能技术生成

文档:Hyperf文档Hyperf框架官方文档https://hyperf.wiki/2.2/#/zh-cn/db/querybuilder

一:准备环境

基于宝塔环境,安装php7.4,

Hyperf 2.2 需要PHP版本 >= 7.3,推荐使用7.4以上的版本。

删掉禁用函数

安装需要的扩展:redis,和 swoole4

 手动安装pcntl扩展:

进入pcntl所在的目录

cd /www/server/php/74/src/ext/pcntl

执行下面命令,安装

/www/server/php/74/bin/phpize

./configure --with-php-config=/www/server/php/74/bin/php-config

make && make install

安装完,建议看一下是不是enabled

<?php

phpinfo();

 通过 Composer 创建项目

composer create-project hyperf/hyperf-skeleton

composer install

启动项目

cd hyperf-skeleton
php bin/hyperf.php start

如果有报错,请查看php版本

php -v

看看是不是7.4

[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.
ERROR Swoole short function names must be disabled before the server starts, please set swoole.use_shortname='Off' in your php.ini.

去php.ini 加一行

swoole.use_shortname=Off

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值