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 !
Thnx in advance.
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
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
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
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
来源:https://stackoverflow.com/questions/40800616/call-to-undefined-function-symfony-polyfill-mbstring-iconv-strlen