Composer Install - requires ext-mbstring
Asked Answered
A

5

6

I am trying to do a composer install ..., but getting an error of requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system. I am using Apache (Cpanel) and PHP 5.6.

Below are the ways I am trying to fix the error.

1: yum search mbstring

============================================= N/S matched: mbstring =============================================
ea-php54-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php55-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php56-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php70-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php71-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
ea-php72-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
rh-php56-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
rh-php70-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
rh-php71-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling

2: yum install ea-php56-php-mbstring.x86_64

Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
 * EA4: 110.4.45.120
 * cpanel-addons-production-feed: 110.4.45.120
 * base: ftp.cuhk.edu.hk
 * centosplus: ftp.cuhk.edu.hk
 * epel: ftp.cuhk.edu.hk
 * extras: ftp.cuhk.edu.hk
 * ius: hkg.mirror.rackspace.com
 * updates: ftp.cuhk.edu.hk
Package ea-php56-php-mbstring-5.6.35-1.1.5.cpanel.x86_64 already installed and latest version
Nothing to do

It seems mbstring is installed but why I got an error when I try to composer install?

Another way (update PHP version in cPanel)

1: WHM - already set to 7.1

enter image description here

2: cPanel - already set to 7.1

enter image description here

but version in server still 5.6

enter image description here

Any suggestions to resolve require ext-mbstring error?

Antaeus answered 23/4, 2018 at 9:27 Comment(4)
What does php -m yield? Is mbstring listed there? If not, you should enable that PHP extensionLawman
Possible duplicate of Composer - the requested PHP extension mbstring is missing from your systemLawman
Solved. The package names are different. So, this post may be good to remind others to double check what they have in their serverAntaeus
please post the package name for the next person ;)Clapper
A
3

Installing rh can solve this issue yum install rh-php56-php-mbstring.x86_64

Please double check what you have in your server. Mine is rh-php56-php-mbstring.x86_64 not php-mbstring

Antaeus answered 23/4, 2018 at 10:21 Comment(0)
F
9

Try installing mbstring php library with aptitude.

sudo apt-get install php-mbstring php7.1-mbstring
Flesh answered 20/7, 2018 at 16:38 Comment(0)
A
3

Installing rh can solve this issue yum install rh-php56-php-mbstring.x86_64

Please double check what you have in your server. Mine is rh-php56-php-mbstring.x86_64 not php-mbstring

Antaeus answered 23/4, 2018 at 10:21 Comment(0)
M
2

Use this command to install mbstrig

 yum install php-mbstring

Once installed restart apache

 service httpd restart
Manthei answered 23/4, 2018 at 9:37 Comment(7)
No package php-mbstring available.Antaeus
Restarting apache has no connection to Composer, as Composer does not use ApacheLawman
composer doesn't need apache but the application itself needs apache. Then you must restart apache to enable the php extensionManthei
But the question does not mention any application that is not working, but only the installation process which does not require a running apache process after allLawman
You guys must have some mental problems... Everytime you install an extension you MUST restart apache. Asked or not you must do it everytime. Now giving a negative note because of apache restart is just childish and non sense.Manthei
What if I'm using NGinx? Still have to restart Apache?Micheal
The question says user is running apache.Manthei
T
1

I recently had a similar issue when trying to run a build for my PHP WordPress site. I ended up updating the composer.json with the snippet below in the require section:

# composer.json
# ...

"require": {
  "ext-mbstring": "*", # <-- I've added this
  "ext-gd": "*",
  "php": "7.*",
  "wordpress/wordpress": "*",

  # ...

}

Hopefully this can become useful to others in the future!

Twocolor answered 6/12, 2020 at 21:26 Comment(0)
S
0

If there are no deeper dependencies down the line, you could use a polyfill instead: edit the composer.json and replace the problem line with "symfony/polyfill-mbstring": "~1.0"

https://packagist.org/packages/symfony/polyfill-mbstring

Solorzano answered 28/1, 2019 at 13:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.