问题描述
如何在 OSX 上使用 MAMP 为 php 7.2.1 安装 gmp 扩展?
How to install gmp extension for php 7.2.1 using MAMP on OSX?
我正在尝试使用 php 和这个库 (lcobucci/jwt) 使用椭圆曲线数字签名算法 (ECDSA) 与 P-256 曲线和 SHA-256 哈希算法.
I'm trying to encrypt a token with php and this library(lcobucci/jwt) using the Elliptic Curve Digital Signature Algorithm (ECDSA) with the P-256 curve and the SHA-256 hash algorithm.
运行php脚本时出错:
Symfony Component Debug Exception FatalThrowableError (E_ERROR)
Class 'MdanterEccEccFactory' not found
我发现我缺少 mdanter/ecc
依赖包,所以我尝试运行以下命令.
I figured that I'm missing the mdanter/ecc
dependicy package, so I tried running the following command.
命令运行:
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 扩展的经验并愿意帮助我的人?
I've tried everything I could find researching this error and related to MAMP. But I couldn't solve this problem. Is there anyone here who has experience in adding the gmp php extension to MAMP specificly and is willing to help me out?
注意:我不是一个非常有经验的网络开发人员,我主要创建 iOS 应用程序,我想在 php 中生成一个令牌,所以我可以访问 Apple Music Kit API 资源.
Note: I'm not a very experienced web developer, I mostly create iOS apps and I want to generate a token in php, so I can access the Apple Music Kit API resources.
推荐答案
这是我在 2020
从源下载php https://github.com/php/php-src/releases 选择与您拥有的 MAMP PHP 版本匹配的版本.
Download php from source https://github.com/php/php-src/releases pick the version which is matching with MAMP PHP version you have.
复制您想要的扩展名.这里我们复制gmp目录.
Copy the extension you want. Here we are copying gmp directory.
粘贴到/Applications/MAMP/bin/php/php7.4.1/include/php/ext
Paste it to /Applications/MAMP/bin/php/php7.4.1/include/php/ext
(确保移动到您的 MAMP php 版本目录)
(Make sure to move to your MAMP php version directory)
cd /Applications/MAMP/bin/php/php7.4.1/include/php/ext/gmp
然后运行phpize命令
Then run phpize command
/Applications/MAMP/bin/php/php7.4.1/bin/phpize
第 5 步:
./configure --with-php-config=/Applications/MAMP/bin/php/php7.4.1/bin/php-config
输出如下
然后
make
然后
make install
现在安装好了.
您可以通过以下方式确认
You can confirm it by
/Applications/MAMP/bin/php/php7.4.1/bin/php -i | grep gmp
gmp 支持 =>启用
如果您没有看到启用 gmp 支持,您可能需要在 php.ini 中添加以下内容.
If you didn't see gmp support enabled, you may need to add following to php.ini.
此命令将显示 MAMP php 使用了哪个 php.ini 文件
This command will show you which php.ini file is used by MAMP php
/Applications/MAMP/bin/php/php7.4.1/bin/php -i |grep php.ini"
/Applications/MAMP/bin/php/php7.4.1/bin/php -i | grep "php.ini"
添加extension=gmp.so
重启 MAMP :)
在此处发布屏幕截图,https://mycodde.blogspot.com/2020/01/install-php-gmp-extension-in-mamp-2020.html
这篇关于如何在 OSX 上使用 MAMP 为 php 7.2 安装 gmp 扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!