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
Related
So.. I developed a project with Laravel 9, then I had to upload it to my client's server by FTP ( which was slow and painful ) to find out only afterwards that my client's server PHP version could not go over 8.0. I tried to open the project live link ( to where I uploaded ) and the composer platform check was telling me my project had dependencies on PHP 8.1 and that my version is 8.0.
So I tried tweaking the platform check php file to disable this check, to see if it would work anyways but no, the project was throwing errors.
So I decided to downgrade to laravel 8, because after searching around I read that laravel 8 did not need php 8.1.
I guess I read some wrong information because after tweaking my project to downgrade to laravel 8 and uploading again (painfully by ftp), the platform check was again telling me that my project needed PHP 8.1.
So I disabled again this platform check by editing/tweaking the platform check php file, to see if it would work anyway, and it did work. So all good. but then today I was learning how to check which composer packages had dependencies on a specific php version, and in the process I found out (if I'm not wrong) that laravel 8 has package dependencies that depend on PHP 8.1 ?
Is there a table somewhere I can check which Laravel versions depend on which PHP versions or do I have to run some commands on each project to check these dependencies?
Like in the images below:
Thanks !
Laravel 9 does not require PHP 8.1 it requires PHP 8.0.2
If this a shared project and someone else with PHP 8.1 generated the composer.lock file (or indeed you locally have PHP 8.1 but the server has 8.0) you might end up with packages that require PHP 8.1. Composer resolves and installs packages based on the locally installed PHP version.
You can override this behaviour and ensure everyone gets package deps based on the PHP version you expect to have on production if you use the platform config option in your composer.json e.g. add this to your composer.json
"config": {
"platform": {
"php": "8.0.2"
}
}
Then run
composer update
this should try to fix your package versions to ones that work with PHP 8
Short response no, Laravel 8 requires PHP >= 7.3
From Server Requirements
But, since you downgraded it is possible that some php packages require newer php versions no matter the version chosen for Laravel.
Some hints:
Change dependencies (packages) version, probably downgrade them.
Delete the vendor folder.
Delete composer.lock
Run composer install
Checking your screenshot: with symfony the downgrade will not break anything.
But, check the other package/s ie: tojsverkoyen/css-to-inline-styles requirements.
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)
Hello after I installed Laravel,
I try to update the version 5.5 to 5.6 and unable to throws me an error:
- laravel/framework v5.6.9 requires php ^7.1.3 -> your PHP version (7.0.10) does not satisfy that requirement.
I use XAMPP with PHP 7.2.10.
I installed Composer with php 7 And does not help.
Thanks
Have a look at your composer.json. It is possible that there is a configuration parameter config.platform.php which contains the value 7.0.10. This feature allows to simulate a specific PHP version to composer. If you don't need it, you can remove it or force composer to install anyway by using the --ignore-platform-reqs parameter when updating the packages.
If you are on Linux Debian, you can easily install the latest version of php with sudo apt-get install php x.x. On windows, this link might help. Then, try installing or upgrading Laravel from cmd and it should work sweet! Re-installing the latest verion of XAMPP may also do the work for you.
You have to update your system's PATH environment variable so that it finds the newer version of php from your command line. You might have more than one installed right now, so it uses the first one it finds when it looks through the directories defined in your PATH. After updating the path variable, you might have to log out for it to apply.
You can check the version used by your command line with php --version. To see which version Apache is configured with, use phpinfo().
Lately l've been working with Laravel. I use composer to install packages and artisan for commands.
The problem is that my machine uses Laravel 5.4 not 5.7.
When i run phpinfo() the result is PHP Version 7.2.7. Do you think that the problem is that i don't use the latest version of xampp which it has included php 7?
Based on comment, yes it is related to PHP version. Your PHP CLI version is too low to support newer version of laravel. You need to update or switch PHP CLI to newer version. Server and CLI PHP are separate packages and might have different versions.
No it is not related to PHP version (in this case).
Probably you ran
composer install
which will install dependencies in versions defined in composer.lock to update dependencies run
composer update
For differences between install and update you can refer to this question
From the comments:
laravel/framework v5.5.9 requires php >=7.0 -> your PHP version (5.6.19) does not satisfy that requirement.
Run php -i in the Terminal. Looks like your webserver and your command line (which Composer uses) are using different versions of PHP.
Laravel version depends on your installation way. It's not related to your PHP or XAMPP version. And you are using the latest PHP version, so don't worry about PHP version.
Read the Laravel installation to install the latest version of laravel.
If you using package laravel/installer
Update this package
composer global update
and try to run
laravel new my-app
I am trying to install a library https://github.com/thephpleague/csv via composer but getting following errors i.e
'This package requires php >= 5.5.9 but your php version <5.4.45> does not satisfy that requirement.'
My current PHP version is 5.6.30 but for some reason composer is showing <5.4.45> which is strange.
I am using ACQUIA DEV DESKTOP on WINDOWS and can switch between PHP versions easily and can check PHP version either by a) dpm(phpinfo()); or b) drush php which is showing same version as set in ACQUIA DEV DESKTOP.
This leads to an issue linked with the composer as it's reading a wrong PHP version.
Steps I have followed to install this library i.e
Copied composer.phar file from 'DevDesktop/tools' folder onto my Drupal project root and then via drush used 'composer require league/csv' which gives me this error ....
'This package requires php >= 5.5.9 but your php version <5.4.45> does not satisfy that requirement.'
'drush php' gives me this... 'Psy Shell v0.8.3 by Justin Jileman'
I have checked online resources for the similar errors but none of the solution out there matches my situation hence posting this question.
Not sure if this is linked to the issue but I have noticed 'DevDesktop\tools\drush.bat' have first line i.e
IF "%PHP_ID%"=="" (SET PHP_ID=php5_5)
which I changed to
IF "%PHP_ID%"=="" (SET PHP_ID=php5_6)
Stack stop/start and tried to download 'composer require lease/csv' but no change (same results).
Thanks in advance.
Found a solution for this error and wanted to share so as it helps anyone else having same problem and possibly improve the solution as it seems to be a quick fix while it should be a universal fix :)
If you install Acquia DevDesktop software, composer comes with this by default.
From Acquia DevDesktop software, we can easily switch between php versions and can also set a default php version but that was not helpful when I try to download library via composer which kept on reading version 5.4.
As Acquia DevDesktop supports different PHP versions i.e 5.3, 5.4, 5.5, 5.6, 7. By default composer was reading php version 5.4 and I still need to find the file which needs to be modified so as default php version can be changed for composer.
In my case what I did was...
Go to Program Files > DevDesktop > tools folder.
There are 4 files having different extensions but same name i.e 'composer'. Remove these all files will remove composer from your system.
Download composer.exe from https://getcomposer.org/ and give it a target folder i.e 'Program Files > DevDesktop > php5_6' and install.
Once installed, now go to your project and by using command prompt or drush console, type 'composer require league/csv' which should download all files in your projects 'vendor' folder.