ChatGPT解决这个技术问题 Extra ChatGPT

Composer - 您的系统中缺少请求的 PHP 扩展 mbstring [关闭]

关闭。这个问题需要更加集中。它目前不接受答案。想改进这个问题?更新问题,使其仅通过编辑此帖子专注于一个问题。 4年前关闭。改进这个问题

我最近尝试通过 Composer 安装软件包,但出现错误 the requested PHP extension mbstring is missing from your system. 我从 php.ini 中删除了分号,但它仍然不起作用。我应该怎么办?

我在 php /ext 目录中有它。
@joci,见 this answer
您使用的是什么操作系统(linux/mac/windows)?您使用的是什么网络服务器(iis/nginx/apache/等)?更新 php.ini 文件后,您是否重新启动了网络服务器软件?
我正在使用带有 apache 服务器(MAMP)的 Windows。是的,我重新启动了服务器。
php.ini 中的 mbstring 设置未注释?

s
steven
sudo apt-get install php-mbstring

# if your are using php 7.1
sudo apt-get install php7.1-mbstring

# if your are using php 7.2
sudo apt-get install php7.2-mbstring

# if your are using php 7.4
sudo apt-get install php7.4-mbstring

这可行,但我必须安装特定的 php 版本:sudo apt-get install php5.6-mbstring。使用 apt-cache search mbstring 进行搜索以查看哪些版本适用于您的系统。
apt-get install php7.1-mbstring 也适合我
如果运行此程序返回 Unable to locate package php-mbstring 错误,请先尝试运行 sudo apt-get update
当然,apt-get install php7.2-mbstring
确认在 ubuntu php 7.2.24 上工作(sudo apt-get install php7.2-mbstring)
J
Jens A. Koch

找到您的 php.ini 确保设置了指令 extension_dir=C:\path\to\server\php\ext 并调整路径(设置您的 PHP 扩展目录)确保设置了指令 extension=php_mbstring.dll(未注释)

如果这不起作用并且缺少 php_mbstring.dll 文件,那么这个堆栈的 PHP 安装就会被破坏。


我重新安装了服务器,但没有任何改变。
这很奇怪。也许在 MAMP 寻求支持或简单地切换堆栈.. XAMPP,WPN-XM。
我终于解决了。我在 php.ini 中设置 PHPRC 变量并取消注释 zend_extension=php_opcache.dll。
而且我还安装了 C++ redistributable 和 directx。我不知道哪里出了问题,但它现在完美无缺。
就我而言, php.ini 文件中没有扩展 php_mbstring 的行。所以我使用 sudo apt-get install php7.3-mbstring 安装了它。我的 php 版本是 7.3,它就像魅力一样工作。
M
Michel

对于 php 7.1

sudo apt-get install php7.1-mbstring

干杯!


这对我不起作用,您使用的是哪个仓库?
在 Ubuntu 18 上,它按上述方式工作。
c
cchapman

我设置 PHPRC 变量并在 php.ini 中取消注释 zend_extension=php_opcache.dll 并且一切正常。


你能更好地解释你做了什么吗?