Cant run composer install because a mismatch in PHP version - php

I have PHP version 8.1.5 as I'm writing this and I'm trying to experiment with older github repo like trix tutorial for example and a problem occurs when I tried to run composer install an error that said
Your lock file does not contain a compatible set of packages. Please run composer update.
Problem 1
- Root composer.json requires php ^7.2.5 but your php version (8.1.5) does not satisfy that requirement.
Problem 2
- doctrine/inflector is locked to version 1.3.1 and an update of this package was not requested.
- doctrine/inflector 1.3.1 requires php ^7.1 -> your php version (8.1.5) does not satisfy that requirement.
Problem 3
- doctrine/lexer is locked to version 1.2.0 and an update of this package was not requested.
- doctrine/lexer 1.2.0 requires php ^7.2 -> your php version (8.1.5) does not satisfy that requirement.
Problem 4
- dragonmantank/cron-expression is locked to version v2.3.0 and an update of this package was not requested.
- dragonmantank/cron-expression v2.3.0 requires php ^7.0 -> your php version (8.1.5) does not satisfy that requirement.
Problem 5
- laravel/framework is locked to version v7.2.1 and an update of this package was not requested.
- laravel/framework v7.2.1 requires php ^7.2.5 -> your php version (8.1.5) does not satisfy that requirement.
...
I certainly don't want to downgrade my PHP version is there a way to upgrade those packages to be compatible with my PHP version?
so far I've tried
change my composer.json file
"require": {
"php": ">=8.1.5",
...
},
and
"require": {
"php": ">=7.2.5",
...
},
and running both composer install and composer update php --with-all-dependencies

You can also use Composer's --ignore-platform-reqs switch to install packages. It will install packages without complaining, but it's not guaranteed that your code will run.

Related

Error when Installing a Package in Laravel 8.15 and php 8.0.2

I am getting the error when installing a laravel Package.
Please help me out. I am using PHP Version 8.0.2 and Laravel Framework 8.15.0
$ composer require hnhdigital-os/laravel-number-converter
here is the error
**
Using version ^1.1 for hnhdigital-os/laravel-number-converter
./composer.json has been updated Running composer update
hnhdigital-os/laravel-number-converter Loading composer repositories
with package information Updating dependencies Your requirements could
not be resolved to an installable set of packages.
Problem 1
- spatie/laravel-permission is locked to version 3.17.0 and an update of this package was not requested.
- spatie/laravel-permission 3.17.0 requires php ^7.2.5 -> your php version (8.0.2) does not satisfy that requirement.
Problem 2
- yajra/laravel-datatables-oracle is locked to version v9.14.1 and an update of this package was not requested.
- yajra/laravel-datatables-oracle v9.14.1 requires php ^7.1.3 -> your php version (8.0.2) does not satisfy that requirement.
Problem 3
- dompdf/dompdf v0.8.6 requires php ^7.1 -> your php version (8.0.2) does not satisfy that requirement.
- barryvdh/laravel-dompdf v0.8.7 requires dompdf/dompdf ^0.8 -> satisfiable by dompdf/dompdf[v0.8.6].
- barryvdh/laravel-dompdf is locked to version v0.8.7 and an update of this package was not requested. Installation failed,
reverting ./composer.json and ./composer.lock to their original
content.
**

Error "Root composer.json requires php ^7.3 but your php version (8.0.0) does not satisfy that requirement" [duplicate]

This question already has answers here:
Override PHP base dependency in composer
(8 answers)
Closed 2 years ago.
I have an unusual error while running the composer install command.
It requires PHP 7.3 while I have PHP 8.0.0. This question is different from Override PHP base dependency in composer, because I have a higher version of PHP (8.0.0) than it required. Why is it not working?
Problem 1
- Root composer.json requires php ^7.3 but your php version (8.0.0) does not satisfy that requirement. Problem 2
- asm89/stack-cors is locked to version v2.0.1 and an update of this package was not requested.
- asm89/stack-cors v2.0.1 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement. Problem 3
- laravel/framework is locked to version v8.10.0 and an update of this package was not requested.
- laravel/framework v8.10.0 requires php ^7.3 -> your php version (8.0.0) does not satisfy that requirement. Problem 4
- laravel/tinker is locked to version v2.4.2 and an update of this package was not requested.
- laravel/tinker v2.4.2 requires php ^7.2 -> your php version (8.0.0) does not satisfy that requirement. Problem 5
- facade/flare-client-php is locked to version 1.3.6 and an update of this package was not requested.
- facade/flare-client-php 1.3.6 requires php ^7.1 -> your php version (8.0.0) does not satisfy that requirement. Problem 6
- facade/ignition is locked to version 2.4.1 and an update of this package was not requested.
- facade/ignition 2.4.1 requires php ^7.2.5 -> your php version (8.0.0) does not satisfy that requirement. Problem 7
- fzaninotto/faker is locked to version v1.9.1 and an update of this package was not requested.
- fzaninotto/faker v1.9.1 requires php ^5.3.3 || ^7.0 -> your php version (8.0.0) does not satisfy that requirement. Problem 8
- nunomaduro/collision is locked to version v5.0.2 and an update of this package was not requested.
- nunomaduro/collision v5.0.2 requires php ^7.3 -> your php version (8.0.0) does not satisfy that requirement. Problem 9
- asm89/stack-cors v2.0.1 requires php ^7.0 -> your php version (8.0.0) does not satisfy that requirement.
- fruitcake/laravel-cors v2.0.2 requires asm89/stack-cors ^2.0.1 -> satisfiable by asm89/stack-cors[v2.0.1].
- fruitcake/laravel-cors is locked to version v2.0.2 and an update of this package was not requested.
From the comments its found that the following command will work for some extend. Its also works for my case
composer install --ignore-platform-reqs
It's because in your project in composer.json file you have:
"require": {
"php": ">=7.3",
.....
},
Try to update this requirement to:
"require": {
"php": "^7.3||^8.0",
.....
},

Composer & Plesk, encountering PHP version difficulties

Am currently attempting to get my Laravel application running behind Plesk Onyx. Now when trying to run composer install, I get the following error messages:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for doctrine/inflector v1.3.0 -> satisfiable by doctrine/inflector[v1.3.0].
- doctrine/inflector v1.3.0 requires php ^7.1 -> your PHP version (7.0.27) does not satisfy that requirement.
Problem 2
- Installation request for symfony/css-selector v4.0.6 -> satisfiable by symfony/css-selector[v4.0.6].
- symfony/css-selector v4.0.6 requires php ^7.1.3 -> your PHP version (7.0.27) does not satisfy that requirement.
Problem 3
- Installation request for symfony/event-dispatcher v4.0.6 -> satisfiable by symfony/event-dispatcher[v4.0.6].
- symfony/event-dispatcher v4.0.6 requires php ^7.1.3 -> your PHP version (7.0.27) does not satisfy that requirement.
Problem 4
- Installation request for symfony/translation v4.0.6 -> satisfiable by symfony/translation[v4.0.6].
- symfony/translation v4.0.6 requires php ^7.1.3 -> your PHP version (7.0.27) does not satisfy that requirement.
Problem 5
- Installation request for doctrine/instantiator 1.1.0 -> satisfiable by doctrine/instantiator[1.1.0].
- doctrine/instantiator 1.1.0 requires php ^7.1 -> your PHP version (7.0.27) does not satisfy that requirement.
Problem 6
- doctrine/inflector v1.3.0 requires php ^7.1 -> your PHP version (7.0.27) does not satisfy that requirement.
- laravel/framework v5.5.39 requires doctrine/inflector ~1.1 -> satisfiable by doctrine/inflector[v1.3.0].
- Installation request for laravel/framework v5.5.39 -> satisfiable by laravel/framework[v5.5.39].
OK. I understand the errors for sure. I run Debian 9 and "PHP by OS Vendor" is 7.0.27. However, I know that PHP 7.1+ (and even 7.2) is installed on the server, because Plesk'd let me choose (for domains and vhosts) these versions. My question now is: How can I tell composer to use a certain PHP version installed on the server, and how could this work under Debian with Plesk?
Edit: I did not install Composer globally. Just https://getcomposer.org/download/ "Command-line installation".
Here's how:
Find the PHP paths used by Plesk. In my case, this is /opt/plesk/php/. Inside this folder, there are the folders according to PHP versions installed: 7.0, 7.1, 7.2. So php composer.phar install becomes /opt/plesk/php/7.2/bin/php composer.phar install. & it works. :-)
You may use platform setting in composer.json to emulate PHP version:
"config": {
"platform": {
"php": "7.1"
}
},
Composer will assume that PHP version is 7.1 during installation and update, even if you're using 7.0 to actual install.
This will only affect Composer installation and update - if you want to run console commands of your app, you will need to use correct binary (same for web server). However setting this will make your Composer installs and updates more predictable, so it's worth doing it anyway.

How do I install Laravel Collective? It keeps saying "Package requires php 7"

$ composer require "laravelcollective/html":"^5.4.0"
./composer.json has been updated
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
- This package requires php >=7.0.0 but your PHP version (5.6.30) does not satisfy that requirement.
Problem 2
- swiftmailer/swiftmailer v6.0.2 requires php >=7.0.0 -> your PHP version (5.6.30) does not satisfy that requirement.
- swiftmailer/swiftmailer v6.0.2 requires php >=7.0.0 -> your PHP version (5.6.30) does not satisfy that requirement.
- swiftmailer/swiftmailer v6.0.2 requires php >=7.0.0 -> your PHP version (5.6.30) does not satisfy that requirement.
- Installation request for swiftmailer/swiftmailer (locked at v6.0.2) -> satisfiable by swiftmailer/swiftmailer[v6.0.2].
Installation failed, reverting ./composer.json to its original content.
open your composer.json, find or just append at require section.. remove ^ from the version ex : ^5.4.9.. remove ^.. it will use current version rather than installing the latest
"require": {
"php": ">=5.6.4",
"laravelcollective/html": "5.4.*",
},
then, composer update
Well that's because version 5.4 of "laravelcollective/html" does require php 7. Try lowering your version to 5.3

Why composer install --no-dev does not work?

I am developing a package library which has regular dependencies and one dev dependency. Composer recommends to not include the composer.lock file for libraries, so here is the composer.json
{
"name": "myself/mypackage",
"require": {
"php": ">=5.6",
"nesbot/carbon": "~1.20"
},
"require-dev": {
"phpunit/phpunit": "^6.0"
}
}
I want this to be compatible for use with applications running PHP 5.6, and I want to develop it using the latest PHPUnit testing tools which require PHP 7.
On the travis continuous integration testing server, I have a build matrix which runs the PHPUnit tests on PHP > 7 and a linting script:
composer install
./lint-php.bash
phpunit
and on PHP < 7, simply lint the source code:
composer install --no-dev
./lint-php.bash
However, it fails because it ignores the --no-dev flag and tries to install the dev dependency anyway.
Your requirements could not be resolved to an installable set of packages.
Problem 1
- phpunit/phpunit 6.0.7 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.6 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.5 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.4 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.3 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.2 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.1 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- phpunit/phpunit 6.0.0 requires php ^7.0 -> your PHP version (5.6.5) does not satisfy that requirement.
- Installation request for phpunit/phpunit ^6.0 -> satisfiable by phpunit/phpunit[6.0.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.0.7].
Why is it ignoring the --no-dev flag? I just want it to install my regular dependencies and to ignore the require-dev section.
Despite the recommendation, this is because you don't have a composer.lock file, and is actually a requested feature.
First, it tries to resolve all dependencies. If this fails, it aborts. Next, it runs the actual install, and at that time ignores the dev dependencies. Your problem is that it couldn't pass the first step for resolution. So it's not that it ignored the --no-dev flag, it just never made it that far.
Option 1
If you include a composer.lock file, then it skips the dependency resolution and goes straight to installation at which time it will skip the dev dependencies.
Option 2
Since you're not including a library, but rather an executable tool, then instead of fighting the potential dependency conflicts between other dev tools you may include later, just pull it out of composer entirely and use phive (The PHAR Installation and Verification Environment).

Categories