如何在OSX上使用MAMP安装PHP7.2的gmp扩展
如何在OSX上安装PHP7.2.1的gmp扩展 我正在尝试使用php和这个库()对令牌进行加密,使用椭圆曲线数字签名算法(ECDSA)和p-256曲线以及SHA-256哈希算法 运行php脚本时出错:如何在OSX上使用MAMP安装PHP7.2的gmp扩展,php,composer-php,mamp,php-extension,php-gmp,Php,Composer Php,Mamp,Php Extension,Php Gmp,如何在OSX上安装PHP7.2.1的gmp扩展 我正在尝试使用php和这个库()对令牌进行加密,使用椭圆曲线数字签名算法(ECDSA)和p-256曲线以及SHA-256哈希算法 运行php脚本时出错: Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'Mdanter\Ecc\EccFactory' not found composer require mdanter/ecc mdant
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Class 'Mdanter\Ecc\EccFactory' not found
composer require mdanter/ecc
mdanter/ecc v0.5.0 requires ext-gmp * -> the requested PHP extension gmp is missing from your system
我发现我缺少了mdanter/ecc
dependicy包,所以我尝试运行以下命令
正在运行的命令:
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Class 'Mdanter\Ecc\EccFactory' not found
composer require mdanter/ecc
mdanter/ecc v0.5.0 requires ext-gmp * -> the requested PHP extension gmp is missing from your system
输出:
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR)
Class 'Mdanter\Ecc\EccFactory' not found
composer require mdanter/ecc
mdanter/ecc v0.5.0 requires ext-gmp * -> the requested PHP extension gmp is missing from your system
我已经尝试了所有我能找到的方法来研究这个错误和与MAMP相关的问题。但我解决不了这个问题这里有没有人有专门为MAMP添加gmp php扩展的经验并愿意帮助我?
注意:我不是一个经验丰富的web开发人员,我主要创建iOS应用程序,我想用php生成一个令牌,这样我就可以访问Apple Music Kit API资源。你必须从php源代码构建gmp扩展 要安装编译器工具链、gmp库和
autoconf
,您需要Xcode和:
brew install autoconf gmp
extension=gmp.so
由于我的MAPP是随PHP7.2.8提供的,因此我将以这个php版本为例,您可以升级MAPP安装或替换与7.2.1相关的版本。并将php(7.2.8)源代码解压缩到目录中,然后根据php安装配置构建环境并构建扩展:
cd ext/gmp
/Applications/MAMP/bin/php/php7.2.8/bin/phpize
./configure --with-php-config=/Applications/MAMP/bin/php/php7.2.8/bin/php-config
make
make install
将扩展加载配置添加到/Applications/MAMP/bin/php/php7.2.8/conf
中的php.ini
:
brew install autoconf gmp
extension=gmp.so
现在这就行了:
/Applications/MAMP/bin/php/php7.2.8/bin/php composer.phar require mdanter/ecc
以下是我在2020年的表现 从源代码下载php,选择与MAMP php版本匹配的版本 复制所需的扩展名。这里我们正在复制gmp目录 将其粘贴到/Applications/MAMP/bin/php/php7.4.1/include/php/ext (确保移动到MAMP php版本目录) 然后运行phpize命令
/Applications/MAMP/bin/php/php7.4.1/bin/phpize
步骤5:
./configure --with-php-config=/Applications/MAMP/bin/php/php7.4.1/bin/php-config
它输出以下内容
然后
然后
它现在已经安装好了
你可以通过电话确认
/Applications/MAMP/bin/php/php7.4.1/bin/php -i | grep gmp
gmp支持=>已启用
如果您没有看到启用gmp支持,您可能需要在php.ini中添加以下内容
此命令将显示MAMP php使用的php.ini文件
/Applications/MAMP/bin/php/php7.4.1/bin/php-i|grep“php.ini”
添加extension=gmp.so
重新启动MAMP:)
在这里发布了截图,我在运行configure命令时遇到了错误
无法找到gmp.h
我不得不使用带有gmp的--标签来告诉大家通往gmp的好途径
./configure --with-php-config=/Applications/MAMP/bin/php/php7.2.34/bin/php-config --with-gmp=/opt/homebrew/Cellar/gmp/6.2.1
有人有回应吗?我尝试了所有的方法,但没有任何东西是最新的…上面4行命令对我不起作用,我的GMP安装在/usr/local/ceral/GMP/6.1.2_2
,这个命令/Applications/MAMP/bin/php/php7.2.8/phpize./configure--with php config=/Applications/MAMP/bin/php/php7.2.8/bin/php-config
不起作用:(那些命令(路径)用于MAMP安装,而不是自制。@SaurabhMistry-您需要从说明()中的链接下载7.2.8的新版本,然后从该新版本的ext/gmp文件夹中运行终端命令。这应该是公认的答案imho。谢谢,这是唯一对我有效的解决方案。