This question already has answers here:
Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.3.0"
(22 answers)
Closed 2 days ago.
I am getting this error with Laravel 9, I have PHP 8.1.7 installed
Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0".
I can see other have asked the question, bit non of the solutions seem to be working
TIPS
Add this lines in composer.json file:
{
"config": {
"platform-check": false
}
}
Or set the version:
{
"config": {
"platform": {
"php": "7.1.0"
}
}
}
And run composer dump-autoload
I had the same problem and it was because I configured a version of PHP 8.1 on the command-line while I kept the PHP module at 8.0.
So PHP_VERSION_ID gave me 80020, while php -v gave me 8.1.7.
It reminded me to reconfigure the PHP Module to PHP version 8.1:
sudo a2dismod php8.0
sudo a2enmod php8.1
sudo systemctl restart apache2
And then everything worked like intended.
Reference:
phpinfo() and php -v shows different version of PHP
If #eril answer did not help you by disabling old PHP version
sudo a2dismod php8.0
sudo a2enmod php8.1
sudo systemctl restart apache2
also check composer using a correct version of PHP
composer -vvv about 2>&1 | grep "PHP"
if composer about already shows a correct version of PHP,then check to see the real PHP binary path that composer is using by putting PHP_BINARY inside vendor/composer/platform_check.php like this:
if (!(PHP_VERSION_ID >= 80100)) {
$issues[] = 'You are running ' . PHP_VERSION . ' located at: ' . PHP_BINARY;
}
in my case, an old version of php-fpm was enabled.
a2disconf php8.0-fpm
a2enconf php8.1-fpm
sudo systemctl restart apache2
If you install composer globally, just run composer global update. It will solve your problem.
Open your composer.json and check where the 'require' block says 'php'. It has an expression that can put a constraint on the PHP version or version range that is allowed for all of your projects' dependencies.
A good value would be to use the one below. Change it and run composer update afterwards.
"require": {
"php": "^8.0|^8.1",
Contrary to the composer.json which laravel 9 ships with:
"require": {
"php": "^8.0.2",
(see laravel 9 composer.json in the official repository: https://github.com/laravel/framework/blob/9.x/composer.json)
Don't change any thing in your application. In your shard hosting, go to cPanel and find/search Multi PHP Manager. Select your domain or sub domain (whatever you are working with), from dropdown list select PHP 8.1 and apply.
Now find/search PHP Selector and for Current PHP Version select 8.1.
in the same window go to Extensions and enable pdo_mysql.
You are good to go.
Your Composer dependencies require a PHP version ">= 8.1.0"
I had this same issue while I downgraded my php to v7.4 from 8.1. I somehow messed up with php7.4-fpm mod. However, when I again tried to upgrade my php v8.1 composer started to complain about that error.
I simply removed my both php versions that's 7.4 and 8.1 and re-installed only 8.1, which fixed my issue.
To remove, here are the steps I followed....
sudo apt-get purge php8.*
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php8.1
and then finally,
sudo service apache2 restart
If you are simply using git to version your Composer dependencies for a deployment, consider the --ignore-platform-reqs flag.
For more info, see Options at https://getcomposer.org/doc/03-cli.md#install-i
composer update --dry-run --ignore-platform-reqs
--ignore-platform-reqs: ignore all platform requirements (php, hhvm, lib-* and ext-*) and force the installation even if the local machine does not fulfill these. See also the platform config option.
If you are operating on nginx server, It's likely the php-fpm8.1 is not active.
Try to:
sudo systemctl status php-fpm8.1.service
Depends on the status of the php-fpm version, you can act, and if it's stopped, you may want to do the following:
sudo systemctl enable php-fpm8.1.service
sudo systemctl start php-fpm8.1.service
Then double-check the status, and if it's active. You're good to go.
Note: This applies to any php-fpm version, not just 8.1.
Hope this help!
if you use XAMPP, check that the PHP version of your XAMPP is the correct one (the same one you have on your computer). Otherwise, download and install the correct version of XAMPP
Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0".
I faced the same problem.
Just go to Cpanel.
Then PHP Selector
and finally, change PHP version
If you are in the process of upgrading Laravel versions and you switch to the version which requires PHP8 (8 or 9 cant remember)
And you also switch PHP versions,
you need to restart your
php artisan serve
in my case everything is fine
composer.json is fine
php 8.1 is installed
I am using nginx I restart nginx but I found that my configuration is wrong it looks like this
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
so the correct configuration is
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
Hope this will help someone
I had the exact issue.
I added the line phpversion() and found that the version was different from what was set for my apache.
I enabled the php8.1-fpm with this command:
sudo a2enconf php8.1-fpm
After restarting Apache I got it working.
It's just until I find how to solve it but it's working
So that's what i've done :
download php 8.1.9 (nts)
extract it in bin/php/ (i use Laragon)
move php 7.14.19 in a new folder(just for preventing)
and rename my php 8 folder to php 7 folder name
it's still working
Just find the php folder of your server
I have an Ubuntu 16.04.6 machine and need the SOAP extension enabled for PHP 7.4, but right now it's only installed for 7.0 The extension itself is present in path /usr/lib/php/20151012/soap.so
I've used apt-get remove php-soap and the apt-get install php-soap but it does not get installed anywhere except the 7.0 folder. I have noticed in the 7.0 folder there are certain files and symlinks, which I have duplicated into the 7.4 folder structure. /etc/php/7.4/mods-available now contains soap.ini and a symlink to it named 20-soap.ini was placed in folder /etc/php/7.4/fpm/conf.d This is in keeping with all the other extensions, which were all installed almost exactly a year ago when I upgraded PHP.
In the php.ini file I have uncommented extension=soap.so and I have tried changing that line to extension=/usr/lib/php/20151012/soap.so
service php7.4-fpm restart
service nginx restart
All this to no avail. Can someone slap me upside the head and tell me what I'm missing? Should I try deleting previous PHP versions, then reinstalling the soap extension? I've seen threads mentioning specific packages for 7.4 such as php7.4-soap but this is not found in my repositories.
Any help is appreciated!
Try this command apt install php7.4-soap
sudo add-apt-repository ppa:jczaplicki/xenial-php74-temp
sudo apt-get update
sudo apt install php7.4-soap
This is adding an external PPA repository to your system. If you do not trust the maintainer you should not do this, since it possibly exposes your system. Also note that this might work for installing php, but there will not be a guarantee that you recvive updates through it (The word "temp" in the repository name indicates that this is only temporary). I would rather recommend compiling it yourself if you really need to have it installed on 16.04.
Also this will install you php version 7.4.13 , you may have to remove the already installed php 7.4 , and reinstall after you add this ppa
I have installed mongodb on a new Ubuntu 18.04 server. I can access and work with the database through the command line, but cannot access it via PHP, and was wondering how other people have gotten it to work.
Following a new build of Ubuntu 18.04, and installation of LAMP, I ran:
sudo apt install mongodb-server php-pear php7.2-dev
sudo pecl install mongodb
I then added the mongodb.so extension to the php.ini file, and a phpinfo(); page shows mongodb as installed. So far so good.
If I browse to a test php page ($mongo=new Mongo();), the page fails to load though.
Through web searches, I find the https://github.com/alcaeus/mongo-php-adapter page come up a lot, and I have run the composer installation command there, but to no avail.
Installed versions are: Ubuntu 18.04.2 LTS; mongoDBv3.6.3; php 7.2.17; Apache 2.4.29
I was wondering what steps other people who have gotten PHP to work successfully with Mongodb have followed? I plan to scrap this server and start from a fresh VM install again.
I was able to install php-mongodb after adding the ppa repository ondrej/php:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt-get install php-mongodb
try:
sudo apt-get install php-mongodb
worked for me
It appears that you're attempting to use the Mongo class from the legacy driver, but you're using the non-legacy driver so that class doesn't exist. Please look at the documentation for the updated version of the driver here. You might also consider using the MongoDB PHP Library to abstract away many of the driver calls.
Please note that there are also compatibility considerations between your versions of the PHP library, MongoDB, and the MongoDB PHP driver. You can find the compatibility information for them here.
How can I fix this? im trying to do a clean install of wordpress latest on ubuntu 16 running nginx for Php7
When i access :
http://blog.mysite.com/wordpress/
I get:
Your PHP installation appears to be missing the MySQL extension which
is required by WordPress.
How can i resolve this?
Simply install necessary extensions and restart fpm process:
sudo apt-get install php-mysqlnd php-mysqli
sudo /etc/init.d/php7.0-fpm restart
This is a real relief I found this post, which helped me:
How to enable MySQLi extension in php 7?
Basically, if you're running php7 instead of php5 you should run this to resolve this issue:
sudo apt-get install php-mysql
and yes, as #Kris mentioned:
reload your webserver
Ok so i have set up a new symfony3 project using :
Vagrant----Virtualbox----PHP56----MYSQL55----UBUNTUTRUSTY64.
Everything was working correctly until i make a "composer update". I have this error message and i cannot do anything now
Attempted to load class "DOMDocument" from the global namespace
So i found some proposed solution like "install php-xml" but it is already installed with newest version.
Does anyone have a solution or guide me to the right direction to find one
Many thanks
Nico
Had the same issue with PHP 7.0.9, this worked:
sudo apt-get install php7.0-xml
You need to install the php-xml for your php version.
If you have php 5.6. you need to install php5.6-xml. It seems the newest version does not work for older versions.
sudo apt-get install php5.6-xml
sudo service apache2 restart
even sudo apt-get install php-xml works. it takes the current version.