Composer detects 5.6 instead of 7.1 when installing vendor - php

I have installed xampp with different php versions of php (5.6 and 7.1) on my C:
when im trying to composer install for the project to have a vendor folder
it reads the php version of 5.6 instead of the 7.1 windows
I tried searching
and i saw one changing on environmental variable but i cant see the path for php versions
i also try Composer does not detect php7 instead it uses 5.6. How can I set the CLI to use php7
but im using git bash not sudo (because ihave Wiondows as OS)

Related

Why xdebug.so is not in php 8 folder when installing from homebrew?

So I installed php 8 with homebrew and I got the PHP 8 installation folder. However, I am trying to connect xdebug with phpstorm. So when I got to the step of linking the 'zend_extension=' path, the PHP 8.0.1 folder didn't contain xdebug.so(I've looked and searched everywhere it doesn’t exist), I have other versions of PHP like 7.3 and 7.4, and they have xdebug within them maybe its cause I didn't use homebrew to install the 7.3 and 7.4 versions or maybe something else I don't know. I've tried deleting version PHP 8 and installing it again but that won't give me the extensions folder which contains xdebug.so, so I can add that path to the 'zend_extension='
The Xdebug extension is not automatically installed by homebrew by default, but you can easily install it using pecl:
$ cd /usr/local/Cellar/php/8.0.10/bin
$ ./pecl install xdebug

How to switch php version when running composer? [duplicate]

This question already has answers here:
Tell Composer to use Different PHP Version
(26 answers)
Closed 1 year ago.
I have composer installed on windows 8.1. I use it to download drupal distributions and modules. I have also installed acquia dev desktop. As you know that dev desktop comes with different versions of php and it has separate folders for it. I have setup composer to use php 5.6. How can I make it use php 7?
Should I uninstall composer and install again or what?
IF you have multiple php version installed in your system
you can run composer with different versions like
In linux
PHP
usr/local/php usr/bin/composer install
for PHP 7.1
usr/local/php7.1 /usr/local/composer install
actually the idea is which version you wants to run get its bin path and then run the composer.
In Windows.
path/to/php.exe composer install
Hope this helps
If you just want to ignore the php version dependency then you can use this -
--ignore-platform-reqs
Example:
composer require symfony/css-selector --ignore-platform-reqs
This way you don't have to edit Environment variables(windows os) or using any full path of php etc. This very useful when I use different php lib from github which requires different php version set in my windows Environment variables though I have all PHP versions in my WAMP server so it will not be any problem running those lib after installing.
In my case worked with this:
ea-php72 /opt/cpanel/composer/bin/composer update

How to switch between two different php version with composer

I've got a lot of research about it but I found nothing that can help my problem. I'm developing a project for now using laravel5.1 and I'm using PHP5.6 version, however I also want to install the new laravel version which is L5.5 but the minimum PHP requirement is PHP7.0 and I chose the 5.6 version of PHP in my installed composer.
How can I switch this two versions of PHP without reinstalling the composer again and again? So if I work with Laravel5.1 I can use the composer with PHP5.6, otherwise I use Laravel5.5 with PHP7 version.
Note:
I'm using WAMP Server that has PHP5.6 & PHP7 available to use.
Create a Windows batch file that calls the composer.phar file using the php7 binary. Let's call the file composer7.bat:
#echo OFF
:: in case DelayedExpansion is on and a path contains !
setlocal DISABLEDELAYEDEXPANSION
c:\path\to\php7\directory\php.exe "%~dp0composer.phar" %*
Save the file along with the originally installed composer.bat file, mine is located in C:\ProgramData\ComposerSetup\bin\ directory.
Now call the php7 composer with the new command:
composer7 require ...

Tell composer which PHP version to use

I have two projects running php7.0 and 5.6. Now the default version of php cli is 7.0. I need to run composer-update on project 5.6 but the composer is reading php7.0 so it will throw an error since there are features that only compatible in 5.6. Is there a way to tell composer which version to use during composer-install and composer-update without changing the default php-cli?
Yes, you just have to specify which PHP version to use by directly calling the intended PHP bin file.
So, instead of
php composer.phar update
You have to use something like
/path/to/php5.6/bin/php composer.phar update
In my case, on a CentOS server with Plesk (default PHP version was 5.4, but I also had 5.6 and 7.0 installed), I had to use :
/opt/plesk/php/5.6/bin/php composer.phar update

How to use composer for different version of Xampp and php in Windows?

I have different versions of xampp installed in my windows 10 pc . Recently i installed xampp having php version 5.6.x as i have to work on projects requiring php version >= 5.6. I also have composer installed which currently uses
php version 5.4.x of xampp installed before.
My question is how can i make composer use this new version php 5.6 when creating and downloading packages which require minimum of php 5.6. Currently when i try to install packages requiring 5.6 it's giving me error this package requires php >=5.6 but your PHP version (5.4) does not atisfy that requirement.
Thanks in advance
I checked the PATH variable and it contains:
C:\Program Files (x86)\ProccessMaker\Php; C:\xampp\php;
So... maybe you have another program installed with PHP.

Categories