PHP | "The requested PHP extension bcmath is missing from your system." - php

Greetings fellow developers,
I am trying to use composer for a PHP project of mine on a development server I recently booted up and for some reason I am unable to. I successfully installed composer, however, when I try to run the require command I get the following error:
root#webserver:/var/mypersonal/index# composer require php-amqplib/php-amqplib
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/php_openssl.dll' - /usr/lib/php/20151012/php_openssl.dll: cannot open shared object file: No such file or directory in Unknown on line 0
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Using version ^2.6 for php-amqplib/php-amqplib
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- php-amqplib/php-amqplib v2.6.3 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- php-amqplib/php-amqplib v2.6.2 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- php-amqplib/php-amqplib v2.6.1 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- php-amqplib/php-amqplib v2.6.0 requires ext-bcmath * -> the requested PHP extension bcmath is missing from your system.
- Installation request for php-amqplib/php-amqplib ^2.6 -> satisfiable by php-amqplib/php-amqplib[v2.6.0, v2.6.1, v2.6.2, v2.6.3].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/7.0/cli/php.ini
- /etc/php/7.0/cli/conf.d/10-mysqlnd.ini
- /etc/php/7.0/cli/conf.d/10-opcache.ini
- /etc/php/7.0/cli/conf.d/10-pdo.ini
- /etc/php/7.0/cli/conf.d/20-calendar.ini
- /etc/php/7.0/cli/conf.d/20-ctype.ini
- /etc/php/7.0/cli/conf.d/20-exif.ini
- /etc/php/7.0/cli/conf.d/20-fileinfo.ini
- /etc/php/7.0/cli/conf.d/20-ftp.ini
- /etc/php/7.0/cli/conf.d/20-gettext.ini
- /etc/php/7.0/cli/conf.d/20-iconv.ini
- /etc/php/7.0/cli/conf.d/20-json.ini
- /etc/php/7.0/cli/conf.d/20-mysqli.ini
- /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini
- /etc/php/7.0/cli/conf.d/20-phar.ini
- /etc/php/7.0/cli/conf.d/20-posix.ini
- /etc/php/7.0/cli/conf.d/20-readline.ini
- /etc/php/7.0/cli/conf.d/20-shmop.ini
- /etc/php/7.0/cli/conf.d/20-sockets.ini
- /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.0/cli/conf.d/20-sysvsem.ini
- /etc/php/7.0/cli/conf.d/20-sysvshm.ini
- /etc/php/7.0/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, deleting ./composer.json.
I'm assuming it's something to do with the PHP warning I recieve right when running the composer require command but no google search results lead me to the correct direction.
Additionally, I have provided my /etc/php/7.0/cli/php.ini file incase of an error in that file.
https://gist.github.com/anonymous/bc5bac59d684cbf575cef931ef36daf6 (I couldn't include the file in this post due to the character limit on posts.)
Thank you.

You can use function get_loaded_extensions to see if bcmath modul is loaded. Or in terminal php -m or php -m | grep name_of_the_modul
You can install it depending on what OS you are using:
Ubuntu
sudo apt install php7.0-bcmath
CentOS
yum install bcmath

PHP 7.2
Debian - jessie
apt-get update
apt-get install php7.2-bcmath
work like a charm :)

For any version in php Centos use
This solution worked for me
yum install php-bcmath
PHP will take the default version installed in the machine, search for that package and install it.
Delete the file composer.lock file if that is already created and then run again,
composer install
If you run
composer update
it will update whatever default packages are installed in composer.json which might create problem for you.

In Ubuntu 20.04
For php 7.4.3, sudo apt install php7.4-bcmath

For PHP 7.1, the following worked for me:
sudo apt install php7.1-bcmath

If you are using Docker:
bcmath can be installed by running this command inside a container: docker-php-ext-install bcmath

check your php version by type: php --version
you will see something like this:
PHP 7.2.9-1+ubuntu16.04.1 ....
then sudo apt install phpX.X-bcmath where X.X is php version, so for this ^ example it will be sudo apt install php7.2-bcmath
after this check if module existed or not by type php -m | grep bcmath

php 7.2 if you have other version just change it accordingly
For CentOS
sudo yum install php72-bcmath
For Ubuntu
sudo apt install php7.0-bcmath

Run this command, hope it will works
sudo apt-get install php-bcmath

hope this will fix the problem.
sudo apt install php-bcmath

For this problem we should use sudo apt install php-bcmath

Strange thing here
Some month ago I have installed all PHP version in the same manner. In here are the 4 identically configured version of php: 5.6, 7.0, 7.1, 7.2, with the same extensions ( when this was made possible ).
The strange thing was that bcmath is present for all php version excluding 7.1.
In the solution search I arrive here in this question, where the logic's things was confirmed installing bcmath, but in my Linode Debian 9 server the command
apt install php7.1-bcmath
doesn't work, with 3 error messages;
E: Impossible to find the package php7.1-bcmath
E: Impossible to find some package with glob "php7.1-bcmath"
E: Impossible to find a package with the regular expression "php7.1-bcmath"
The goals no meet with any combination of tips and trick, refreshing apt cache, change Debian's mirrored server, installing yum, so on...
After some tentatives I had an illumination: modificating of /etc/apt/sources.list enabling the default Linode repository, then after an apt update (with no solution in the immediate), I have restored the /etc/apt/sources.list commenting out the Linode mirror sources again. Magically, after the new apt update the command now are working.
By this I confirm: apt install php7.1-bcmath is the right command, but your Debian can need a kick in the ass

Install with this command, thats work for me
apt-get install php-bcmath

I tried below package and it worked in Php version 5.6
yum install php56w-bcmath

For those who have already tried installing bc-math and still composer is giving errors.
Try this command
rm composer.lock
It will definitely work

Related

Trying to install php-mbstring on ubuntu 20.04

I'm just trying to create a new laravel project and faced with this message
Creating a "laravel/laravel" project at "./example-app"
Installing laravel/laravel (v8.5.22)
- Installing laravel/laravel (v8.5.22): Extracting archive
Created project in /home/alifirhas/0_Work/Belajar/postgresql/example-app
> #php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/framework[v8.40.0, ..., 8.x-dev] require ext-mbstring * -> it is missing from your system. Install or enable PHP's mbstring extension.
- Root composer.json requires laravel/framework ^8.40 -> satisfiable by laravel/framework[v8.40.0, ..., 8.x-dev].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/8.0/cli/php.ini
- /etc/php/8.0/cli/conf.d/10-opcache.ini
- /etc/php/8.0/cli/conf.d/10-pdo.ini
- /etc/php/8.0/cli/conf.d/20-calendar.ini
- /etc/php/8.0/cli/conf.d/20-ctype.ini
- /etc/php/8.0/cli/conf.d/20-exif.ini
- /etc/php/8.0/cli/conf.d/20-ffi.ini
- /etc/php/8.0/cli/conf.d/20-fileinfo.ini
- /etc/php/8.0/cli/conf.d/20-ftp.ini
- /etc/php/8.0/cli/conf.d/20-gettext.ini
- /etc/php/8.0/cli/conf.d/20-iconv.ini
- /etc/php/8.0/cli/conf.d/20-phar.ini
- /etc/php/8.0/cli/conf.d/20-posix.ini
- /etc/php/8.0/cli/conf.d/20-readline.ini
- /etc/php/8.0/cli/conf.d/20-shmop.ini
- /etc/php/8.0/cli/conf.d/20-sockets.ini
- /etc/php/8.0/cli/conf.d/20-sysvmsg.ini
- /etc/php/8.0/cli/conf.d/20-sysvsem.ini
- /etc/php/8.0/cli/conf.d/20-sysvshm.ini
- /etc/php/8.0/cli/conf.d/20-tokenizer.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Looks like I have to install php-mbstring on my computer, so I run the command
sudo apt-get install php-mbstring
as i found in this thread: laravel/framework requires ext-mbstring
But there is another error message
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php-mbstring : Depends: php8.0-mbstring but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
This is the error code when i run sudo apt install php7.4-mbstring
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
php7.4-mbstring : Depends: libonig5 (>= 6.8.1) but it is not installable
E: Unable to correct problems, you have held broken packages.
What have I tried
Reinstalled php7.4 on my computer then try to install mbstring, but fail
Update my php version to version -8 then try to install mbstring, but fail
Do what is in this thread: https://askubuntu.com/questions/1064634/unable-to-install-php-mbstring, but fail
So does anyone know how to install php-mbstring? or how can i make a laravel project?
I hope you guys can help me with this problem, please. I've been working on this problem for almost 8 hours and still can't find a solution.
Turns out i have to enabled universe repository to my system, like this
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"
sudo apt-get update #to update my system
As Jarad said in this thread Cannot install php-mbstring on ubuntu 18.04. And then i can just run
sudo apt-get install php-mbstring
But turns out, i have to be specific what version that i want to install. If i just run php-mbstring, will just install mbstring for php 8.0 not version installed on system. I have to be specific, then i run command
sudo apt-get install php7.4-mbstring
(I moved to php7.4)
And it run perfectly. Also thank you #Nico Haase and #Peter Krebs for helping.
What works for me is to specify the version, and don't forget to update:
sudo apt update
sudo apt install php7.4-mbstring
Have you tried a system update?
sudo apt-get upgrade
I used this just today, hope it helps you as well.
I came to this issue today for php8.0-mbstring module, and I found that the correct repository i not available in my system so my method was this and it worked for me, hope it will hep you too:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get install php8.0-mbstring

Hosting laravel 5.6 on VPS?

hi guys am trying to host a laravel 5.6 app on a VPS for the first time and i cant seem to get it right..am using LEMP.i followed some guide which was using php 7.0 but my project requires php 7.1 "i think i managed to resolve the error using the following line"
sudo apt-get install php7.1-cli php7.1-fpm php7.1-mbstring php7.1-mysql
php7.1-mcrypt php7.1-curl
now am getting the following error
Problem 1
- Installation request for phpoffice/phpexcel 1.8.1 -> satisfiable by
phpoffice/phpexcel[1.8.1].
- phpoffice/phpexcel 1.8.1 requires ext-xml * -> the requested PHP extension
xml is missing from your system.
Problem 2
- phpoffice/phpexcel 1.8.1 requires ext-xml * -> the requested PHP extension
xml is missing from your system.
- maatwebsite/excel 2.1.28 requires phpoffice/phpexcel ^1.8.1 -> satisfiable
by phpoffice/phpexcel[1.8.1].
- Installation request for maatwebsite/excel 2.1.28 -> satisfiable by
maatwebsite/excel[2.1.28].
this is my first time so any useful information is very welcome :)
You would need to install the php-xml package. You can do it using the following command:
sudo apt-get install php-xml
When the package is installed run the composer install again.
You can read more about this issue here: https://laracasts.com/discuss/channels/servers/how-do-i-install-the-dom-extension-for-php7
edit:
if it does not install the correct version of the package, you can use the command from #Dharma Saputra's comment:
sudo apt-get install php7.1-xml

Your version of PHP does NOT have the intl extension loaded [duplicate]

I need to use the extension intl on my mac with XAMPP.
So I have followed this links:
Php-intl installation on XAMPP for Mac Lion 10.8
http://lvarayut.blogspot.it/2013/09/installing-intl-extension-in-xampp.html
I restart always my apache server but isn't installed the extension. Because if I launch:
php -m | grep intl #should return 'intl'
return empty
The command that I can't launch without it is for composer and cakephp like this:
composer create-project --prefer-dist -s dev cakephp/app cakephp3
Return me this error:
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for cakephp/cakephp 3.0.*-dev -> satisfiable by cakephp/cakephp[3.0.x-dev].
- cakephp/cakephp 3.0.x-dev requires ext-intl * -> the requested PHP extension intl is missing from your system.
Problem 2
- cakephp/cakephp 3.0.x-dev requires ext-intl * -> the requested PHP extension intl is missing from your system.
- cakephp/bake dev-master requires cakephp/cakephp 3.0.x-dev -> satisfiable by cakephp/cakephp[3.0.x-dev].
- Installation request for cakephp/bake dev-master -> satisfiable by cakephp/bake[dev-master].
So I need to solve the problem of ext-intl with the extension intl.
Can someone help me with this problem?
How can I install this extension?
Thanks
These below steps helped me, Just in case if you are using OSX
Steps from http://www.phpzce.com/blog/view/15/installing-intl-package-on-your-mac-with-xampp
Check which php path is set i.e.
root$: which php
If you are using xampp on your mac it should be
/Applications/XAMPP/xamppfiles/bin/php
but if its
/usr/bin/php
you need to change your OSx php
root$: PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}"
Install icu4c
root$: brew install icu4c
Install Intl via PECL
root$: sudo pecl update-channels
root$: sudo pecl install intl
You can check if Intl was installed successfully
root$: php -m | grep intl #should return 'intl'
Done
============================
Note:
From extensions list in /Applications/XAMPP/xamppfiles/etc/php.ini file Add / Uncomment extension=intl.so line. And restart Apache. Thanks #pazhyn
Before installing "intl" you have to install Autoconf if you have not installed it. Thanks #Digant
via Homebrew brew install autoconf automake
or
by running below commands
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
tar xzf autoconf-latest.tar.gz
cd autoconf-*
./configure --prefix=/usr/local
make
sudo make install
cd ..
rm -r autoconf-*
I had issues with intl when using Moodle, which I fixed by doing the following:
Re-run the XAMPP installer (if you don't have the installer on hand, download it from here) and tick the "XAMPP Developer Files"
Use your terminal and go into XAMPP's binary folder $ cd /Applications/XAMPP/bin
Use PHP's package manager to install intl by running $ sudo ./pecl install intl This should compile some things, and if successful, the installation should complete with:
Build process completed successfully
Installing '/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20131226/intl.so'
install ok: channel://pecl.php.net/intl-3.0.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=intl.so" to php.ini
$ cd ../etc There you will have your php.ini to which you have to add extension=intl.so On my system I appended the line after line 959, which you can find by searching for php_intl
Finally restart your Apache web server from the XAMPP GUI.
Hope this works for you!
I had the same problem with XAMPP.
I tried several answers but without success.
Could solve lowering an alternative library http://php-osx.liip.ch/.
This library php, comes already installed intl and several other package.
After downloading went to httpd.conf in xampp and LoadModule php5_module pointed to these packages in /usr/local/php5/libphp5.so

Installation of Magento 2 error: php ext-gd is required

I am trying to install magento/product-community-edition 2.1.3 in cloud9 (Ubuntu 14.04.3 LTS) with PHP 7.0.15
I get the following error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for magento/product-community-edition 2.1.3 -> satisfiable by magento/product-community-edition[2.1.3].
- magento/product-community-edition 2.1.3 requires ext-gd * -> the requested PHP extension gd is missing from your system.
To enable extensions, verify that they are enabled in those .ini files:
- /home/ubuntu/.phpbrew/php/php-7.0.15/etc/php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
I tried to do the following installation on install php70-gd on ubuntu but I still get the same error afterwards.
How will I successfully install magento 2?
Use following command to install the gd extension:
sudo apt-get install php5.6-gd
it will work for PHP version 5.6
If you are using any other verison of PHP, replace 5.6 by that like:
sudo apt-get install php7.0-gd
for PHP 7.0
run
sudo apt-get install php5.6-gd
or
sudo apt-get install phpX.X-gd
then check your .ini files:
To enable extensions, verify that they are enabled in your .ini
files:
- /etc/php/7.0/cli/php.ini
change
;extension=...
to extension=... for each dependency you need.
If the error is still there, check the PHP version on your localhost/server and the PHP version that you are using with your Magento.
Be aware that all versions of PHP are not compatible to Magento.
More informations: http://devdocs.magento.com/guides/v2.0/comp-mgr/trouble/cman/php-version.html
Good luck!
PS: If you got the same issue for ext-mcrypt, ext-dom or anything else, you will have to follow the same process and then re-run the composer installation.
sudo apt-get install php7.0-dom
sudo apt-get install php7.0-mcrypt
sudo apt-get install php7.0-curl

Run php composer.phar install Error

I am trying to install composer while SSHed on a vagrant machine. Whenever I run php composer.phar install I get the following error:
vagrant#precise64:/vagrant$ php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for doctrine/migrations dev-master -> satisfiable by doctrine/migrations[dev-master].
- doctrine/migrations dev-master requires php ^5.5|^7.0 -> your PHP version (5.4.45) does not satisfy that requirement.
I do not know what to do with the first 'installation request for doctrine...' problem and when I check run php -v I have php 5.5.27 installed. I have also tried sudo php composer.phar install. Any insight?
Your box, precise64 (Ubuntu 12.04) likely has an outdated version of PHP on it.
There are a couple of ways you could approach upgrading PHP. For the sake of simplicity and modularity, we will focus just on upgrading PHP.
SSH into the box:
vagrant ssh
The version of PHP you need is not available by default in the Precise repos IIRC. Add a PPA which has an updated version:
sudo apt-get update
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:ondrej/php5
sudo apt-get update
Remove existing PHP:
sudo apt-get purge php5
Check the install candidate, it should be at least 5.5 (it's 5.5.33+ for me as of this post):
sudo apt-cache policy php5
Install the updated version of php5:
sudo apt-get install php5
And now composer should work just fine for you.
It seems there are several PHP are installed on your machine. Use the below command to check the first php in your PATH environment.
which php

Categories