I'm using the doctrine/dbal (v2.4.*) package in my PHP project. My production server runs PHP v5.6.
I ran composer update this morning which updated my composer.lock file. Now, when I'm deploying to production, I see this:
Problem 1
- Installation request for doctrine/inflector v1.2.0 -> satisfiable by doctrine/inflector[v1.2.0].
- doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version (5.6.14) does not satisfy that requirement.
Problem 2
- doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version (5.6.14) does not satisfy that requirement.
- doctrine/common v2.4.3 requires doctrine/inflector 1.* -> satisfiable by doctrine/inflector[v1.2.0].
- Installation request for doctrine/common v2.4.3 -> satisfiable by doctrine/common[v2.4.3].
Specifically these:
doctrine/common v2.4.3 requires doctrine/inflector 1.* -> satisfiable by doctrine/inflector[v1.2.0].
doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version
(5.6.14) does not satisfy that requirement
This means, that even if dbal is old, it requires the newest common, and common requires the newest inflector package. Problem is that inflector started depending on PHP7 to run.
Is there any way in Composer to limit updating of the packages to those supported by specific PHP version? Like saying: "Please update what you can, but only if the server's PHP version is sufficient."
Use the platform option in your composer.json file to define the PHP version your production environment is using like this:
{
"config": {
"platform": {
"php": "5.6.14"
}
}
}
see https://getcomposer.org/doc/06-config.md#platform
Remove composer.lock file
Run composer install
Related
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.
I need to deploy Doctrine on php version 5.6.30. It is possible? If so, how should I set dependencies in composer.json?
Problem 1
- Installation request for doctrine/annotations v1.5.0 -> satisfiable by doctrine/annotations[v1.5.0].
- doctrine/annotations v1.5.0 requires php ^7.1 -> your PHP version (5.6.30) does not satisfy that requirement.
Problem 2
- Installation request for doctrine/cache v1.7.1 -> satisfiable by doctrine/cache[v1.7.1].
- doctrine/cache v1.7.1 requires php ~7.1 -> your PHP version (5.6.30) does not satisfy that requirement.
Problem 3
- Installation request for doctrine/collections v1.5.0 -> satisfiable by doctrine/collections[v1.5.0].
- doctrine/collections v1.5.0 requires php ^7.1 -> your PHP version (5.6.30) does not satisfy that requirement.
Problem 4
- Installation request for doctrine/common v2.8.1 -> satisfiable by doctrine/common[v2.8.1].
- doctrine/common v2.8.1 requires php ~7.1 -> your PHP version (5.6.30) does not satisfy that requirement.
Problem 5
- Installation request for doctrine/dbal v2.6.2 -> satisfiable by doctrine/dbal[v2.6.2].
- doctrine/dbal v2.6.2 requires php ^7.1 -> your PHP version (5.6.30) does not satisfy that requirement.
Problem 6
- Installation request for doctrine/inflector v1.2.0 -> satisfiable by doctrine/inflector[v1.2.0].
- doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version (5.6.30) does not satisfy that requirement.
Problem 7
- Installation request for twig/twig v2.4.3 -> satisfiable by twig/twig[v2.4.3].
- twig/twig v2.4.3 requires php ^7.0 -> your PHP version (5.6.30) does not satisfy that requirement.
Try removing any Doctrine dependencies from composer.json, delete composer.lock and call composer via CLI:
composer require doctrine/orm
The composer itself will pick best dependencies to match your PHP version.
Delete composer.lock and run composer install help.
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).
I'm on a new development machine, and I'm having issues installing Laravel, Spark, or just about anything that requires anything newer than PHP 5.5.30.
The problem is, I'm using MAMP Pro which IS running PHP 7.0.1. I've also tried to update my system's PHP version to PHP 7 using this tutorial: https://coolestguidesontheplanet.com/upgrade-php-on-osx/
☁ /webroot spark new app
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
- This package requires php >=5.6.4 but your PHP version (5.5.30) does not satisfy that requirement.
Problem 2
- Installation request for laravel/framework v5.3.20 -> satisfiable by laravel/framework[v5.3.20].
- laravel/framework v5.3.20 requires php >=5.6.4 -> your PHP version (5.5.30) does not satisfy that requirement.
Problem 3
- Installation request for phpunit/php-code-coverage 4.0.1 -> satisfiable by phpunit/php-code-coverage[4.0.1].
- phpunit/php-code-coverage 4.0.1 requires php ^5.6 || ^7.0 -> your PHP version (5.5.30) does not satisfy that requirement.
Problem 4
- Installation request for phpunit/phpunit 5.6.2 -> satisfiable by phpunit/phpunit[5.6.2].
- phpunit/phpunit 5.6.2 requires php ^5.6 || ^7.0 -> your PHP version (5.5.30) does not satisfy that requirement.
Problem 5
- Installation request for phpunit/phpunit-mock-objects 3.4.0 -> satisfiable by phpunit/phpunit-mock-objects[3.4.0].
- phpunit/phpunit-mock-objects 3.4.0 requires php ^5.6 || ^7.0 -> your PHP version (5.5.30) does not satisfy that requirement.
Problem 6
- Installation request for sebastian/code-unit-reverse-lookup 1.0.0 -> satisfiable by sebastian/code-unit-reverse-lookup[1.0.0].
- sebastian/code-unit-reverse-lookup 1.0.0 requires php >=5.6 -> your PHP version (5.5.30) does not satisfy that requirement.
Problem 7
- Installation request for sebastian/object-enumerator 1.0.0 -> satisfiable by sebastian/object-enumerator[1.0.0].
- sebastian/object-enumerator 1.0.0 requires php >=5.6 -> your PHP version (5.5.30) does not satisfy that requirement.
Problem 8
- Installation request for sebastian/resource-operations 1.0.0 -> satisfiable by sebastian/resource-operations[1.0.0].
- sebastian/resource-operations 1.0.0 requires php >=5.6.0 -> your PHP version (5.5.30) does not satisfy that requirement.
Problem 9
- Installation request for sebastian/version 2.0.0 -> satisfiable by sebastian/version[2.0.0].
- sebastian/version 2.0.0 requires php >=5.6 -> your PHP version (5.5.30) does not satisfy that requirement.
Application ready! Build something amazing.
Downloading Spark...
I don't want to just bypass the required PHP version by editing in the composer file, because I'm not sure if it's causing problems when installing apps or not. None of my Spark or Laravel installations work, they just give a 500 status error, it could be something else, but I was assuming it was this same problem.
All fixed.
Thanks #Kyslik for your suggestion.
I had previously tried updating my PATH, but for some reason it worked this time. I must have made a mistake before. For reference of anyone else having this issue, I followed this:
How to override the path of PHP to use the MAMP path?
I have a problem with some bundle, i use bundle: vich/uploader-bundle 1.0.1
so my project run only on PHP 7.0 ... how to downgrade some bundle to use PHP 5.6.20 ?
composer install:
Problem 1
Installation request for ocramius/package-versions 1.0.4 -> satisfiable by ocramius/package-versions[1.0.4].
ocramius/package-versions 1.0.4 requires php ~7.0 -> your PHP version (5.6.20) does not satisfy that requirement.
Problem 2
Installation request for ocramius/proxy-manager 2.0.1 -> satisfiable by ocramius/proxy-manager[2.0.1].
ocramius/proxy-manager 2.0.1 requires php ~7.0 -> your PHP version (5.6.20) does not satisfy that requirement.
Problem 3
ocramius/proxy-manager 2.0.1 requires php ~7.0 -> your PHP version (5.6.20) does not satisfy that requirement.
vich/uploader-bundle 1.0.1 requires ocramius/proxy-manager ~1.0|~2.0 -> satisfiable by ocramius/proxy-manager[2.0.1].
Installation request for vich/uploader-bundle 1.0.1 -> satisfiable by vich/uploader-bundle[1.0.1].
In your composer file add the PHP version config key like this:
"config": {
"platform": {
"php": "5.6"
}
},