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
15
Answers
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:
And then everything worked like intended.
Reference:
It’s just until I find how to solve it but it’s working
So that’s what i’ve done :
Just find the php folder of your server
TIPS
Add this lines in
composer.json
file:Or set the version:
And run
composer dump-autoload
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….
and then finally,
If @eril answer did not help you by disabling old PHP version
use
composer -vvv about
to check that composer use correct version of PHPif 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
insidevendor/composer/platform_check.php
like this:in my case, an old version of php-fpm was enabled.
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
If you are operating on
nginx
server, It’s likely thephp-fpm8.1
is not active.Try to:
Depends on the status of the
php-fpm
version, you can act, and if it’s stopped, you may want to do the following:Then double-check the status, and if it’s active. You’re good to go.
Note: This applies to any
php-fpm
version, not just8.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
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.
Contrary to the composer.json which laravel 9 ships with:
(see laravel 9 composer.json in the official repository: https://github.com/laravel/framework/blob/9.x/composer.json)
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
If you install composer globally, just run
composer global update
. It will solve your problem.in my case everything is fine
so the correct configuration is
Hope this will help someone
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 selectPHP 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 enablepdo_mysql
.You are good to go.
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:After restarting Apache I got it working.