Call to undefined function Symfony\\Polyfill\\Mbstring\\iconv_strlen()

旧城冷巷雨未停 提交于 2019-12-03 05:57:12

Symfony provides an iconv-polyfill for cases like that. 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.

To check that, run php --ri iconv with any SSH software, like Putty, etc.

If it shows Extension 'iconv' not present., your problem is in PHP. Then you have a few options:

  • 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

Here is a solution to your problem (command line is for CentOS) :

Solved: If you are using Cpanel/WHM STACK then follow: Go to WHM >> EasyApache4 >> Current Installed Packages >> customize

Now Select php extensions and search for iconv and debug install both of them and try to install again.. enjoy :)

I had the same error message when I installed Mbstring extension but did not restart 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

To find your Apache location use

$ 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:

die(phpinfo()); 

BTW

it is really easy to install extension with MacPorts, For my PHP 5.6 I have done just:

$ 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:

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:

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:

Enter to your WHM then type "EasyApache 4" then click "EasyApache 4" and click "Customize". you can see in the picture

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 Extensions

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. then the iconv package has succeeded. try typing the composer again so you don't get any more errors

php --ri iconv

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!