How to solve Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2" - laravel

After uploading my Laravel version 8.5 files. I keep getting this display instead of the landing page:
Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2".
I've run the following commands:
a2dismod php7.4
a2enmod php8.1
service apache2 restart
update-alternatives --set php /usr/bin/php8.1
update-alternatives --set phar /usr/bin/phar8.1
update-alternatives --set phar.phar /usr/bin/phar.phar8.1
I've also restarted Apache with:
/etc/init.d/apache2 restart
But I keep getting the same display, even after clearing my browser cache.
I'm sure Apache is still referencing the former PHP version according to:
phpinfo()
Full Disclosure:
I'm not proficient with Linux. My OS is Ubuntu 20.04, while my old PHP version is 7.4.29 and new PHP version is 8.1

Had the same issue. Found that there were multiple versions of php installed and Apache was referencing one of the former PHP versions. Disabled each former version using a2dismod until the right version was being referenced. Hope this helps.

Try to update your php version in your composer.json file.
"require": {
"php": "^8.0.2"
}
and then run composer update.

I don't think it's your PHP that's the problem. I think it is your Composer configuration. Composer is the link between your PHP and your apps. See How to solve Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.2"

Related

Why i cannot install Laravel Breeze

I installed a fresh laravel application using version 7.30.4. When I tried to install laravel breeze, using command composer require laravel/breeze --dev, it gives me this error.
[InvalidArgumentException]
Package laravel/breeze has a PHP requirement incompatible with your PHP version, PHP extensions and Composer version
My current version of PHP is 7.2.19
This error comes due to compatible version in your composer.json file. To fix this issue, change the composer.json file "platform" configuration:
"platform": {
"php": "7.3"
}
Then execute composer install or composer update
or you can run the below command:
composer config platform.php 7.4.3
Laravel breeze required PHP version 7.3 and as you said your PHP version is 7.2.19 so you have to update it.

laravel new blog not work mockery/mockery 1.4.0

Today I wanted to create a new project with Laravel with this command
laravel new blog
But I get this error
Crafting application...
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for mockery/mockery 1.4.0 -> satisfiable by mockery/mockery[1.4.0].
- mockery/mockery 1.4.0 requires php ^7.3.0 -> your PHP version (7.2.23) does not satisfy that requirement.
Why should php7.3 be read when Laravel himself says at least php7.2.5 ???
Run composer update.
The reason:
Your PHP version is too low. You've got 7.2.23 installed, and mockery/mockery 1.4 requires 7.3.0
The best solution is to upgrade your PHP version. Alternatively, you can reduce mockery's version to 1.3.1, which only requires PHP 5.6 or above.
My bug report can be found here
As of 2020-05-21, the zip files that laravel new ___ uses will try to install mockery/mockery version 1.4. This won't work with versions of PHP below 7.3. In order to fix this, run composer update, and mockery will be downgraded to a compatible version.
I had the same problem today for new Laravel projects. The composer.json file was showing "mockery/mockery": "^1.3.1" but still was showing the same error. Delete also the composer.lock file and run composer install.
Assuming you are trying to create a new laravel project called blog this is what I did to fix the error after running laravel new blog
cd into blog
run composer update
Create a .env file. You can just make a copy of .env.example and rename the copy to .env. In case you try to start the dev server using php artisan serve and the app launches with a 500 error, run these commands:
php artisan key:generate
php artisan cache:clear
php artisan config:clear
composer dump-autoload
I had the problem when trying to create new Laravel applications,I updated php version using the following commands and it worked.
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt install -y php7.4 php7.4-gd php7.4-mbstring php7.4-xml
Delete the composer.lock file and run composer again
composer install
You can just run
composer create-project --prefer-dist laravel/laravel <project_name>
It'll automatically fall-back to mockery^1.3.1
I also faced these problems.
Problem 1
- Installation request for facade/ignition-contracts 1.0.2 -> satisfiable by facade/ignition-contracts[1.0.2].
- facade/ignition-contracts 1.0.2 requires php ^7.3|^8.0 -> your PHP version (7.2.34) does not satisfy that requirement.
Problem 2
- Installation request for mockery/mockery 1.4.2 -> satisfiable by mockery/mockery[1.4.2].
- mockery/mockery 1.4.2 requires php ^7.3 || ^8.0 -> your PHP version (7.2.34) does not satisfy that requirement.
Problem 3
- facade/ignition-contracts 1.0.2 requires php ^7.3|^8.0 -> your PHP version (7.2.34) does not satisfy that requirement.
- nunomaduro/collision v4.2.0 requires facade/ignition-contracts ^1.0 -> satisfiable by facade/ignition-contracts[1.0.2].
- Installation request for nunomaduro/collision v4.2.0 -> satisfiable by nunomaduro/collision[v4.2.0].
I had deleted the composer.lock file and executed composer install command.
My problem solved.
This might be stale, the issue here is that the php needs to be updated to version that will be compatible.
delete the composer.lock file and autoload file in vendor i.e vendor/autoload in your project
upgrade php version from php.net
run composer install --no scripts
run composer update
php artisan migrate
php artisan key:generate

laravel homestead - different php version

We are using the latest homestead, where you can fill in the php version in homestead.yml.
I installed php 7.0 with "sudo apt-get install php7.0-fpm".
But from my point of view this php version is not used in my project.
I did a composer update and it takes php 7.1 as basis for the composer.lock.
How to use the php version 7.0 for my composer?
to check what is you cli php version run
php -v
to change it to php 7.0 run
php70

How to install PhpUnit with XAMPP using composer?

Im trying to install PHPUnit on Xampp using Composer.I have followed the steps from the following link
http://woeiyu.com/software/php/installing-phpunit/
but im got the error "proc_open(NUL): failed to open stream: No such file or directory" while executing composer update
I suggest you skip XAMPP and use Git. Much easier. But you actually don't need those two to install it.
Put this in your composer.json
{
"require-dev": {
"phpunit/phpunit": "5.0.*"
}
}
Run it like this in Git or XAMPP composer update after that composer install
and that's it. You successfully downloaded and installed PHPUnit. It's located in your root vendor/
You can install phpunit with composer globally using
$ composer global require phpunit/phpunit
For reference see https://getcomposer.org/doc/03-cli.md#global.

Composer error - Your requirements could not be resolved - Laravel 4.2 on Mediatemple

I'm getting a problem reported from composer when running php -d allow_url_fopen=On composer.phar install on mediatemple.
This reports back saying laravel/framework v4.2.6 requires php >=5.4.0 -> no matching package found.
I've updated my php version to be 5.5, but i'm not sure if the above problem is referring to my php version or the laravel/framework package when it says "no matching package found".
when I run the above command, it shows that it is 'installing dependencies (including require-dev)' but i get the problem reported above.
my minimum stability is set to "stable"
could someone help clarify?
It turns out I was using php v5.3 on the CLI while I was running php 5.5 on the domain successfully as they had told me.
In order to use the latest php version on the CLI, i had to run php-latest composer.phar install instead of php composer.phar install
I found this link helpful: https://yesdevnull.net/2014/03/using-php-54-cli-on-media-temples-grid-hosting/

Resources