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.
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 get the following error when running mPDF in my browser. I have just installed the latest version of mPDF on my cloud server running PHP 7.4. The requirements page for mPDF say I should be able to run this version with PHP 7.3+
I have tried to resolve the issue in composer.json but have no success. I am not able to install PHP 8.0 without upgrading the hosting which I do not want to do.
Any direction is appreciated.
Error message:
Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0".
If you would like to learn why the php package is required (this may sound stupid, but think about it as a requirement with a specific version), you can make use of composer-depends(1), a.k.a. why?:
$ composer why php
...
composer/semver 3.2.6 requires php (^5.3.2 || ^7.0 || ^8.0)
doctrine/annotations 1.13.2 requires php (^7.1 || ^8.0)
...
It gives an alphabetical listing of packages in your configuration and which php version they require. This should help you to spot which package requires ^8.0.0 / >= 8.0.0 to get a better understanding.
When your target platform has PHP 7.4, you can configure your project to always depend on that version. This works by specifying the platform php version as a configuration option.
Get the exact php version on your target platform, e.g. 7.4.30 (Aug 2022).
Note: PHP 7.4.x is going to end of life this year[1], consider upgrading the hosting within the next two months to 8.0 at least (if changing hosting for the PHP version is hard, consider to already go to 8.1, test your project with each version first thought, best done locally).
Then within your project configure that version as the projects target platform version:
$ composer config platform.php 7.4.30 # (1.)
# (no output)
1. replace the exemplary version 7.4.30 with your target platform version
After changing the Composer project configuration this way, you need to update the projects dependencies:
$ composer update
# ...
Now Composer will no longer infer the available version of the php platform package (the PHP version) from the environment but instead take the configured platform version. Your local PHP version is not interfering any longer to resolve the installable set of packages. Instead, the configured platform PHP version is used for the resolution.
This effectively prevents that you pull in packages that require a higher PHP version.
Commit all changes to the configuration (composer.json) and pinned versions (composer.lock) and use those to do the packaging for the deployment to the target platform.
I have two xampp versions in my machine one have php version 5.4 and other having 7.1(recently installed.) I usually use composer command to download laravel. previously i get laravel version 5.0.X when i download because of my php vesrion(5.4) but even after installing new xampp(having php version 7) composer is downloading laravel 5.0.x only. When i check my php version it is showing 5.4 now how can i choose or connect latest php version to composer so that i will get latest laravel version.
Finally i found the solution. I changed my composer path to new php version and now getting what i want.
I set my Environment variables as follow:
change name of respective document xampp that contains your project I want to launch.
my system context
I'm a student and pretty new to web development so forgive me if I'm missing something obvious. I recently attended a hackathon and was on a team with experienced developers who were building an app for deployment on AWS using the the Silex framework. Everyone else was using a Mac, while I have a PC running Windows 10. When they integrated AWS PHP SDK v3 from packagist I was unable to run the composer update function from the command line - I kept getting the following message:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- aws/aws-sdk-php 3.3.5 requires php >=5.5 -> your PHP version (5.4.24) or "
config.platform.php" value does not satisfy that requirement.
Because I was unable to run the composer update function, I wasn't able to update my app code and I couldn't continue to work on the project. This was frustrating, but I'm also just very confused about how to update PHP on my computer... I downloaded the zip file for PHP 5.6.13-nts and followed all the instructions I could find online for placing it in a folder structure, I also updated IIS so I can run phpinfo() on localhost and see that I have version 5.6.13 - yet when I try to run the composer update it still says I have PHP 5.4.24.
If anyone has any advice on this issue I'd appreciate it. Here's the version of the AWS SDK that's referenced above:
https://packagist.org/packages/aws/aws-sdk-php-silex
Welcome to StackOverflow, Blake!
It seems that you have multiple PHP versions installed and the CLI command php composer.phar ... uses php.exe from the old version. My guess is that the old version is still on the env path.
I suggest to check your environment path to find out, if the path to the old version of PHP is still added there. If so, simply replace it by the path to the new PHP version. And then execute a simple php -v on the CLI to see, if the new version is used. After that Composer should run fine.
You reach the dialog to change the environment variables by pressing WinBreak, then select "Advanced system settings", then "Environment Variables", then "Path".
(Sidenote and shameless plug: there are pre-configured web development stacks for Windows out there: WPN-XM or XAMPP, just to name a few. They are made to save developers some time, instead of doing software installation and configuration. Some of them ship Composer and other tools relevant for development with PHP right out of the box.)
I have a Vagrant machine with the actual PHP version I want my server to run on, but locally I use a newer version of PHP.
Updating Composer locally just saves so much time as opposed to updating it on the virtual machine via SSH.
So my question is: Does it affect the vendor files when composer install or update is called from different versions of PHP?
The PHP version used when updating the dependencies affects the packages being used. Packages can define a requirement on a certain PHP version.
A common requirement found is requiring PHP 5.4 or 5.5 when a package is using the features of said versions, or PHP 5.3.3 or PHP 5.3.27 because the package needs certain bugfixes.
Composer will complain about not being able to execute composer install if the PHP version used when running this command is not able to fulfill all PHP version requirements that are mentioned in the lock file.
Running composer update with an older PHP version than composer install probably will work in most cases. Using the same PHP version should be the recommended setting, though.
Also: Using the same required extensions in all PHP versions also is needed for requirements checking.
Note that there is some demand for Composer to assume a given PHP version or extension is present on the target platform even if the command line PHP running the Composer command does not fulfill them, but this feature is not implemented yet. So there is no way to override the local PHP version with the one present on the target environment.