Call to undefined function Symfony\Polyfill\Mbstring\iconv_strlen()
Solution 1
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
Solution 2
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
Solution 3
Here is a solution to your problem (command line is for CentOS) :
Solution 4
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
Solution 5
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 :)
SlimenTN
A software developer who is in love with programming I work on Web, desktop and mobile apps but I'm a big fan with web technologies and JS frameworks. I have recently worked on building a PHP framework based on MVC architecture: Github link: https://github.com/SlimenTN/Limpid Site: http://sbc.tn/limpid And for now I'm focusing on Angular framework and progressive web apps. Some things I did with love: Limpid (an MVC based PHP framwork) LogTrackerBundle (Symfony Bundle for tracking exception and logs) FlexiAnimate (JavaScript module for animating html DOMs based on the famous library Animate.css) SFCollectionAnalyze (JavaScript Module for generating templates for Symfony's CollectionType) Co-Developer of NotificationsBundle (Symfony Bundle based on Pusher API to provide realtime data broadcast) SlarnAutocomplete: Simple yet powerful autocomplete for Angular
Updated on August 05, 2022Comments
-
SlimenTN over 1 year
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.
-
SlimenTN over 7 yearsThnx it worked. Also thnx to @qooplmao for his answer :)
-
visulo about 7 years@Michael I have the same problem, how to do for fix the error?
-
Michael Hirschler about 7 years@nabil didn't my solution work for you too? If so, please open up a new question and provide as many information as you can. You maybe need a different solution for a different problem.
-
visulo about 7 yearsThanks, I found the solution with cpanel WHM : cyberpersons.com/2016/10/21/…