My host updated composer version ( 2.2 ) without updating php version ( 7.0.33 ).
When I run composer [command], I get this error:
Composer 2.3.0 dropped support for PHP <7.2.5 and you are running 7.0.33-0+deb9u12, please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.
I don't have the option to downgrade composer (composer self-update --2.2 give me the same ) and this php version is locked.
So I decided to use /opt/plesk/php/7.4/bin/php /usr/lib/plesk-9.0/composer.phar [command] instead and it works. I think php /usr/lib/plesk-9.0/composer.phar will work too.
I'm using Symfony 4 and now I need to deploy my application. But when I try php bin/console doctrine:schema:update --dump-sql composer detect issues because my dependencies require a higher php version than defined in var
PHP Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 7.2.5". You are running 7.0.33-0+deb9u12. in /var/www/vhosts/client-name/httpdocs/vendor/composer/platform_check.php on line 24
First question: Why composer is called when I try to update my database using doctrine CLI?
What I tried
I run composer config platform.php 7.0.33
Some of my dependencies are now too new, so I'm trying to downgrade them to the latest major version.
I changed the version of PHP and in libraries in the "require" section and I run /opt/plesk/php/7.4/bin/php /usr/lib/plesk-9.0/composer.phar update --with-dependencies ( because just composer cause me problems )
It doesn't work for doctrine which need PHP 7.1 and I don't want to go back to doctrine 1 ( doctrine 2.0 was released in 2010 )
Second question: Do you have any suggestion? I don't see an immediate solution
I had the same issue and I had to upgrade PHP by running:
$ brew unlink php#7.1
$ brew link php#8.1
Hope that can help someone.
If you have the same problem than me, you may need to call symfony command using PHP binaries directly:
/opt/plesk/php/7.4/bin/php bin/console d:s:u --dump-sql
Related
since the latest php fpm docker image update yesterday (https://hub.docker.com/_/php?tab=tags&page=1&name=fpm-alpine) my pipeline is broken because apparently PHP version 8 is installed instead of 7.4 as in my Dockerfile specified.
I am using this in my docker file:
FROM php:7.4-fpm-alpine AS ...
But according to my composer installs the container has PHP 8.0.13 running:
Root composer.json requires php 7.4.26 but your php version (8.0.13) does not satisfy that requirement.
Anyone an idea what is going on here?
As Jeremy Brooks already mentioned, Alpine released version 3.15 where composer requires PHP 8 (https://pkgs.alpinelinux.org/package/v3.15/community/x86_64/composer). Instead of installing composer from getcomposer.org another solution is to use Alpine 3.14:
FROM php:7.4-fpm-alpine3.14 AS ...
The alpine PHP images you reference do not include composer, so how are you installing it? If you are using apk to installer composer, it looks like the latest alpine composer package is pulling php8 in as a dependency, and this is causing your issue. What solved this issue for me was to install composer using the install script from getcomposer.org instead of using apk.
Assuming this is what you are doing, remove this from your Dockerfile:
RUN apk add composer
and add:
ADD https://getcomposer.org/installer ./composer-setup.php
RUN php ./composer-setup.php --install-dir=/usr/local/bin --filename=composer
RUN rm ./composer-setup.php
If composer is indeed included in your base image (unlikely), you could try uninstalling first:
RUN apk delete composer
and then add the above code to install it from the setup script instead.
Edit: adding the ignore-platform-reqs flag will probably get you past the error, but you are introducing a possible point of failure in the future if you have a composer package with a platform requirement. In that case, you won't know about the error until runtime. I would not recommend that approach. The method I posted above will install composer using the version of PHP already on the system and will not require risky workarounds.
I'm currently working on my docker-compose file to install laravel 8 with php 8.
I tested "php:7.4-fpm-alpine", and when I access the container I'm getting this version of php :
/var/www/html # php --version
PHP 7.4.26 (cli) (built: Nov 30 2021 08:21:51) ( NTS )
You can test it yourself :
docker container ls
docker exec -it <container_id> sh
php --version
I'm getting PHP 8.0.13 when installing "php:8.0-fpm-alpine"
Also I'm creating my laravel project using the composer image, I don't have php/composer installed locally. It's something you might have a look, because it could be quickly confusing ;-)
I had the same problem today...
Try:
composer install --no-scripts --ignore-platform-reqs
Fixed it for me.
Code and Idea are from
https://stackoverflow.com/users/564000/armin
I want to generate a Symfony application which can be compatible with PHP version up to 7.4.22.
On my local machine, PHP version is 8.0.2 but on the hosting is 7.4.22.
Symfony application is generated from local machine using standard composer command
composer create-project symfony/website-skeleton my_project_name
I look over create-project arguments to see if I could add some constrains but none seems to be useful.(or didn't figure out)
If try to upload to host the project I get this when trying to install it:
Your Composer dependencies require a PHP version ">= 8.0.0". You are running 7.4.22.
Need just a default empty project to check something on hosting.
I do not want to alter local PHP and doing the same thing on hosting could be troublesome.
You cannot add a "dependency constraint" to create-project.
E.g. Something like an imaginary create-project symfony/skeleton --dep php: "^7".
What you could do is:
first create-project
Add the config.platform key to your composer.json adjusted to your server's version (Docs.)
Run composer update
Either some packages will be downgraded if needed, or you'll get a message telling you that the new, target version is incompatible.
E.g. after doing a create-project symfony/skeleton and changing config.platform.php to 7.2, on executing composer update I get:
Your requirements could not be resolved to an installable set of packages.
Running composer create-project symfony/website-skeleton my_project_name in an example project using PHP 8 installs psr/cache in v2 and psr/link in v1.1.1. These package versions require PHP 8, and they will not work using any older version of PHP.
To avoid this, just don't run composer create-project with any later version than the one you want to use on your production system (as usually, running it with a lower PHP version than on production yields a set of packages that is compatible with the production system, while the chance is lower the other way around).
Otherwise, check whether there are such package versions using composer why-not php 7.4 before deploying and downgrade them
I'm getting the following error in a project I'm setting up:
You are using Composer 2, which some of your plugins seem to be incompatible with. Make sure you update your plugins or report a plugin-issue to ask them to support Composer 2.
I've started at a new company this week, just trying to get their projects installed and there doesn't seem to be a way to change my composer version on Windows. I'd rather not update all their packages as I'm not familiar with the projects yet and have no clue what kind of implications go into that.
Assuming a regular composer installation, to rollback to version 1 of composer, you simply execute:
composer self-update --1
When you want to go back to version 2 (which you should, after updating or removing the incompatible plugins):
composer self-update --2
The above will take you to the latest on any of the two major versions.
You can also "update" to a specific version just by passing the version number to self-update:
composer self-update 1.10.12
composer self-update 2.0.7
After performing any self-update, you can specify --rollback to go back to the previously installed version.
composer self-update
composer self-update --rollback
Finally, if you are feeling adventurous, you can update to a pre-release version by executing:
composer self-update --preview
If you have already installed composer on your system. then paste the below code to downgrade the composer version with a specific version as per your need.
composer self-update 1.10.14
for ubuntu system use the below command
sudo -H composer self-update 1.10.14
Just two commands worked for me. Currently I have composer 2.x.x , I had 1.10.x . First one command will download downgrade version and then second command will rollback to 1.x.x
php composer self-update --1
composer self-update --rollback
I found a flag in composer installer "--1" and "--2".
I'm using this command inside of my Dockerfile:
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer --1
You can use following code for update to specific versions
composer self-update 1.10.12
composer self-update 2.0.7
or
composer self-update --1 or 2
The below command is used to update the specific version of the composer.
composer self-update [version no of composer]
Use phar instead.
Download specific version of composer.phar file from :
https://getcomposer.org/download
Place this phar file in your project root directory where you are trying to run composer install/update/require
now instead of composer require use php composer.phar require
Is it possible to set the installation order?
Currently I'm using Doctrine module that requires ext-mongo to be installed, but as I'm using the newer php version (7.0) I have mongodb installed instead. There's a alcaeus/mongo-php-adapter package that resolves installation problems. But there's one problem - Composer is trying to install Doctrine modules first, so that installation fails.
Currently I have to resolve this problem manually, but I can't do it any more as I'm going to pack my environment to a Docker image to let it be automatically deployed later.
From the docs of alcaeus/mongo-php-adapter
"
$ composer require alcaeus/mongo-php-adapter
If your project already has a dependency on ext-mongo, the command above may not work. This is due to a bug in composer, see https://github.com/composer/composer/issues/5030
To fix this, you can use the --ignore-platform-reqs switch when running the above command, or when running composer update with no composer.lock file present."
Running a CI build on codeship.io returns into an unexplainable error. The last lines of the debug text is:
[..]
Clearing the cache for the dev environment with debug true
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets handling the post-install-cmd event terminated with an exception
[ErrorException]
Undefined property: Composer\Script\CommandEvent::$getIO
The codeship documentation doesn't say much about deploying/building a Symfony application. It seems like it is impossible to create the bootstrap.php.cache file.
EDIT:
I'm using Symfony 2.4.3-DEV, composer is unable to finish the post-install-cmd scripts, so it looks like composer has no i/o interface at Codeship. Adding composer self-update to the install script at Codeship does result in the same error.
The codeship configuration is:
# Set php version through phpenv. 5.3, 5.4 and 5.5 available
phpenv local 5.4
# Install dependencies through Composer
composer selfupdate
composer install --prefer-source --no-interaction --optimize-autoloader
Have you specified PHP in the Select your technology to prepopulate basic commands field ? What are your Setup Commands ?
Mine are :
phpenv local 5.5
composer install --prefer-source --no-interaction
php app/console assetic:dump --env=prod