php 调用未定义的函数 Symfony\Polyfill\Mbstring\iconv_strlen()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40800616/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Call to undefined function Symfony\Polyfill\Mbstring\iconv_strlen()
提问by SlimenTN
My project works fine on localhost but not working online and this is the error:
我的项目在本地主机上运行良好,但不能在线运行,这是错误:
Fatal error: Call to undefined function Symfony\Polyfill\Mbstring\iconv_strlen() in /home/stram/public_html/vendor/symfony/polyfill-mbstring/Mbstring.php on line 338
I googled it and I found that I need to install the PHP extension iconv
. The problem that I'm using a VPS and when I went to the list of available PHP extensions I didn't found this extension !
我用谷歌搜索,我发现我需要安装 PHP 扩展iconv
。我使用的是 VPS 的问题,当我转到可用的 PHP 扩展列表时,我没有找到这个扩展!
Thnx in advance.
提前谢谢。
回答by Michael Hirschler
Symfony provides an iconv-polyfill for cases like that. Just add it as requirement to your project, and you should be fine:
Symfony 为这种情况提供了 iconv-polyfill。只需将它作为要求添加到您的项目中,您应该没问题:
composer require symfony/polyfill-iconv
回答by Lucas Bustamante
It may also happen that you are using an outdated version of PHP, orone that was compiled without iconv.
也有可能您使用的是过时的 PHP 版本,或者没有 iconv 编译的版本。
To check that, run php --ri iconv
with any SSH software, like Putty, etc.
要检查这一点,请php --ri iconv
使用任何 SSH 软件(例如 Putty 等)运行。
If it shows Extension 'iconv' not present., your problem is in PHP. Then you have a few options:
如果它显示扩展名“iconv”不存在。,您的问题出在 PHP 中。然后你有几个选择:
- Run php -v to check your PHP version, and update it if necessary
- Or compile PHP again with iconv
- Or enable iconv on WHM/cPanel, if you use them
- Or ask your hosting company for support
- 运行 php -v 以检查您的 PHP 版本,并在必要时更新它
- 或者用 iconv 再次编译 PHP
- 或者在 WHM/cPanel 上启用 iconv,如果你使用它们
- 或向您的托管公司寻求支持
回答by yasin
回答by Gyanaranjan Pradhan
Solved: If you are using Cpanel/WHM STACKthen follow: Go to WHM >> EasyApache4 >> Current Installed Packages >> customize
已解决:如果您使用的是Cpanel/WHM STACK,请按照以下步骤操作:转到 WHM >> EasyApache4 >> Current Installed Packages >> Customize
Now Select php extensionsand search for iconvand debuginstall both of them and try to install again.. enjoy :)
现在选择php 扩展并搜索iconv并调试安装它们并再次尝试安装.. 享受 :)
回答by Nasir Usman
If you use WHM with the CentOS 7 operating system you will encounter errors like this when typing "composer" on the console:
如果你在 CentOS 7 操作系统上使用 WHM,你会在控制台输入“composer”时遇到这样的错误:
Fatal error: Uncaught Error: Call to undefined function Symfony\Polyfill\Mbstring\iconv() in phar:///opt/cpanel/composer/bin/composer/vendor/symfony/polyfill-mbstring/Mbstring.php:661 Stack trace:
致命错误:未捕获错误:调用 phar:///opt/cpanel/composer/bin/composer/vendor/symfony/polyfill-mbstring/Mbstring.php:661 中未定义的函数 Symfony\Polyfill\Mbstring\iconv() 堆栈跟踪:
0 phar:///opt/cpanel/composer/bin/composer/vendor/symfony/polyfill-mbstring/bootstrap.php(48): Symfony\Polyfill\Mbstring\Mbstring::mb_strwidth('help', 'ASCII')
0 phar:///opt/cpanel/composer/bin/composer/vendor/symfony/polyfill-mbstring/bootstrap.php(48): Symfony\Polyfill\Mbstring\Mbstring::mb_strwidth('help', 'ASCII')
......
......
The solution is to install the iconv package using WHM:
解决方案是使用 WHM 安装 iconv 包:
Enter to your WHM then type "EasyApache 4" then click "EasyApache 4" and click "Customize". you can see in the picture
输入您的 WHM,然后键入“EasyApache 4”,然后单击“EasyApache 4”并单击“自定义”。你可以在图片中看到
Select PHP Extensions, type "iconv" in the search and check the version of php that you will use to install the iconv package. see in the picture
选择 PHP 扩展,在搜索中输入“iconv”并检查您将用于安装 iconv 包的 php 版本。在图片中看到
Choose Review
选择评论
Click Provision
点击设置
To ensure that the iconv package is installed you can use this command "php --ri iconv" if the results are like this in the picture. then the iconv package has succeeded. try typing the composer again so you don't get any more errors
为确保安装了 iconv 包,如果结果如图所示,您可以使用此命令“php --ri iconv”。那么 iconv 包就成功了。尝试再次输入作曲家,以免出现更多错误
回答by Yevgeniy Afanasyev
I had the same error message when I installed Mbstring extension but did not restart Apache.
当我安装 Mbstring 扩展但没有重新启动 Apache 时,我收到了相同的错误消息。
All that needed is to do
所有需要做的就是
$ sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart
Yeah, I have a long path here, but it is just for me. It is because I use MacPorts
是的,我在这里有很长的路要走,但它只适合我。这是因为我使用 MacPorts
To find your Apache location use
要查找您的 Apache 位置,请使用
$ ps ax | grep apache
P.S.
聚苯乙烯
I don't have iconv
extension installed too. At list it is not listed when I call php info like so:
我也没有安装iconv
扩展。在列表中,当我像这样调用 php info 时没有列出它:
die(phpinfo());
BTW
顺便提一句
it is really easy to install extension with MacPorts, For my PHP 5.6
I have done just:
使用 MacPorts 安装扩展真的很容易,对于我来说,我PHP 5.6
只做了:
$ sudo port install php56-mbstring