How to rectify Call to undefined function Symfony\Component\Console\Helper\mb_detect_encoding() after installing composer?
Asked Answered
U

4

12

I am using ubuntu 21.04 in that i installed composer by using this command sudo apt-get install composer ,after installing i type composer it's showing following error

HP Fatal error:  Uncaught Error: Call to undefined function Symfony\Component\Console\Helper\mb_detect_encoding() in /usr/share/php/Symfony/Component/Console/Helper/Helper.php:50
Stack trace:
#0 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(329): Symfony\Component\Console\Helper\Helper::strlen('h')
#1 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(97): Symfony\Component\Console\Descriptor\TextDescriptor->calculateTotalWidthForOptions(Array)
#2 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(197): Symfony\Component\Console\Descriptor\TextDescriptor->describeInputDefinition(Object(Symfony\Component\Console\Input\InputDefinition), Array)
#3 /usr/share/php/Symfony/Component/Console/Descriptor/Descriptor.php(55): Symfony\Component\Console\Descriptor\TextDescriptor->describeApplication(Object(Composer\Console\Application), Array)
#4 /usr/share/php/Symfony/Component/Console/Helper/DescriptorHelper.php(67): Symfony\Component\Console\Descriptor\Descriptor->describ in /usr/share/php/Symfony/Component/Console/Helper/Helper.php on line 50

please help me to fix this issue

Urbanist answered 31/8, 2021 at 9:47 Comment(0)
O
23

You simply enable mbstring extension it will remove the uncaught error

sudo apt-get install php7.2-mbstring
Olenolin answered 31/8, 2021 at 9:55 Comment(1)
For php 7.4 , use sudo apt-get install php7.4-mbstring .. Similarly replace the version number in comand based on current php version installed in machine.Kuster
M
4

Hello I encountered this issue on php8.2 while the stack trace differs from OP doing as mentionned by @MiraTech @user16784870 or @Jay-Teli fixed this error :

sudo apt-get install php8.2-mbstring
Martinez answered 2/2 at 9:42 Comment(2)
Or just sudo apt-get install php-mbstring to get package related to currently used version (php --version)Elasticize
It's possible that the solution you provided is correct. However, I would need to verify this again if I were to work on the PHP project again, as it is unclear whether the command you recommended would work with the specific version of PHP used in the project.Martinez
A
3

If you're using PHP 7.4:

sudo apt-get install php7.4-mbstring
Apocarp answered 1/11, 2022 at 18:15 Comment(0)
H
0

Check phpinfo.php for ctype module information. In my case, it wasn't loaded and I didn't see the following:

ctype module loaded

I activated it in php.ini (location depends on your configuration):

;extension=curl
extension=ctype # uncomment or add this
;extension=ffi

and restart php service. You should see ctype module's block and error should go away.

Housing answered 17/1, 2023 at 12:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.