Run php composer without any output - php

I had composer v.1.3.2, today I updated it to 1.4.1, after done, I run 'composer' as usual but see nothing output. My php version is 7.1.3. OS is CentOS 7 in vagrant. (Composer below is composer.phar 1.4.1)
I've tried rm composer cache and re-download composer.phar. Even composer 1.3.2 can not work now.
Unexpected I found composer.phar can run by PHP v7.0.
Then I upload the same composer.phar to another CentOS 7 which has php v7.1.3. Composer works well there.
Have any idea about it? Any tips will be appreciated.

Related

How to override composer problem detection when using Symfony command line

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

PHP-FPM Alpine Docker Image 7.4 installs PHP version 8.0

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

How to downgrade or install a specific version of Composer?

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

How to update Composer in Windows 10

I am using Composer for my PHP project. I am new to Composer. Now when I update my dependencies using composer update command, it is saying that my Composer version is too old and ask me to update. So I tried as below. But all failed.
My composer.phar file is in C:/ProgramData/ComposerSetup/bin/composer.phar
I opened terminal and tried
composer.phar update
php composer.phar update
composer C:/ProgramData/ComposerSetup/bin/composer.phar update
php composer C:/ProgramData/ComposerSetup/bin/composer.phar update
When I run composer-self-update, error as in screenshot.
All command failed. I am using XAMPP. There is no composer.phar file in xampp/php folder as well. How can I update Composer in Windows 10?
Try
composer self-update
If this doesn't work check your PATH variable, if it's not there try searching composer.bat in windows and add it to your PATH variable. Normally, its in following path.
C:\ProgramData\ComposerSetup\bin
Windows 10 update for Composer still works (end of 2020, pre version 2) with:
Follow This below Image:
composer self-update --1 it will be updated from 1.x
composer self-update --2 it will be updated from 2.x and from 1.x
composer self-update --rollback If you need to rollback to your previous version
composer -V For check your composer version
composer self-update:
If you run composer self-update from 1.x, it will warn you that a new stable major version of Composer is available, and you can use composer self-update --2 to migrate to it.
So run composer self-update --2
How easy is it to upgrade?
Composer 2.0 still supports PHP 5.3 and above, much like Composer 1.x
composer.lock files are interoperable between versions, so you can
upgrade to 2.0 and roll back easily if needed.
Most commands and arguments remain the same, and largely what you
know about Composer remains true in 2.0.
Windows 10 update for Composer still works (end of 2020, pre version 2) with:
composer self-update
If you need to rollback to your previous version, you can do that with:
composer self-update --rollback
Try.
php composer.phar self-update
'update' updates your dependencies not composer itself.
Use
composer self-update --2
By default, the installer and composer self-update will download the latest stable version only.
To programmatically install specific major versions you can use the --1 or --2 flag.
To go back to the previous version:
composer self-update --rollback
To check the current version
composer --version

Installing laravel on mac os via composer

I need to use lavarel on mac os. I first installed MAMP. After that, following instructions on laravel.com, I installed composer globally via homebrew. Now, when I change my directory to /Applications/ MAMP/htdocs and try composer create-project laravel/laravel myname on the terminal, nothing happens even after half an hour.
I also tried downloading lavarel-master manually,putting the content in htdocs and composer install .Again nothing in .5 hour.
I have done composer self-update and checked composer diag and all is OK.
Upon trying which php ,i get /Applications/MAMP/bin/php/php5.5.10/bin/php
I also restarted mac and tried the commands again,but same result.
Please help ,I am new to php and don't know how to proceed.
PS:Upon trying composer install in laravel master directory the following appears on terminal:
Loading composer repositories with package information
Installing dependencies (including require-dev) and then only the cursor blinks, nothing happening. Is that a trouble with my composer or laravel installation?

Categories