简体   繁体   English

调用未定义的函数Symfony \\ Polyfill \\ Mbstring \\ iconv_strlen()

[英]Call to undefined function Symfony\Polyfill\Mbstring\iconv_strlen()

My project works fine on localhost but not working online and this is the error: 我的项目在localhost上运行良好,但无法在线工作,这是错误:

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 . 我用Google搜索了它,发现需要安装PHP扩展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 ! 我正在使用VPS的问题,当我转到可用的PHP扩展列表时,找不到该扩展!

在此处输入图片说明
在此处输入图片说明
在此处输入图片说明

Thnx in advance. 提前thnx。

Symfony provides an iconv-polyfill for cases like that. Symfony为此类情况提供了iconv-polyfill。 Just add it as requirement to your project, and you should be fine: 只需将其添加为项目的要求,就可以了:

composer require symfony/polyfill-iconv

It may also happen that you are using an outdated version of PHP, or one that was compiled without iconv. 您可能还会使用过时的PHP版本, 或未使用iconv编译的版本。

To check that, run php --ri iconv with any SSH software, like Putty, etc. 要进行检查,请使用任何SSH软件(例如Putty等)运行php --ri iconv

If it shows Extension 'iconv' not present. 如果显示扩展名“ iconv”不存在。 , your problem is in PHP. ,您的问题出在PHP中。 Then you have a few options: 然后,您有几个选择:

  • Run php -v to check your PHP version, and update it if necessary 运行php -v检查您的PHP版本,并在必要时进行更新
  • Or compile PHP again with iconv 或再次使用iconv编译PHP
  • Or enable iconv on WHM/cPanel, if you use them 或在WHM / cPanel上启用iconv(如果使用它们)
  • Or ask your hosting company for support 或向您的托管公司寻求支持

Here is a solution to your problem (command line is for CentOS) : 这是您的问题的解决方案(命令行用于CentOS):

EasyApache

Solved: If you are using Cpanel/WHM STACK then follow: Go to WHM >> EasyApache4 >> Current Installed Packages >> customize 解决:如果您使用的是Cpanel / WHM STACK,请遵循:转到WHM >> EasyApache4 >>当前安装的软件包>>自定义

Now Select php extensions and search for iconv and debug install both of them and try to install again.. enjoy :) 现在选择php扩展并搜索iconv调试安装它们,然后尝试再次安装..享受:)

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 

PS 聚苯乙烯

I don't have iconv extension installed too. 我也没有安装iconv扩展。 At list it is not listed when I call php info like so: 在列表中,当我像这样调用php信息时未列出该列表:

die(phpinfo()); 

BTW 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

If you use WHM with the CentOS 7 operating system you will encounter errors like this when typing "composer" on the console: 如果将WHM与CentOS 7操作系统一起使用,则在控制台上键入“ 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". 输入您的WHM,然后键入“ EasyApache 4”,然后单击“ EasyApache 4”,然后单击“自定义”。 you can see in the picture 你可以在图片中看到

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. 选择“ PHP扩展”,在搜索中键入“ iconv”,然后检查将用于安装iconv软件包的php版本。 see in the picture 在图片中看到

PHP Extensions PHP扩展

Choose Review 选择评论

Review 评论

Click Provision 点击设置

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. 如果结果如图所示,则可以确保安装了iconv软件包,可以使用此命令“ php --ri iconv”。 then the iconv package has succeeded. 那么iconv软件包就成功了。 try typing the composer again so you don't get any more errors 尝试再次输入作曲家,这样您就不会再出现任何错误

php --ri iconv php --ri iconv

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM