New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to handle multiple php versions requirements? #4090
Comments
I tweeted something similar @Seldaek about the same time you posted this. So far the only solution I've come up with is having different major versions targeting different PHP versions, but then users cannot rely on Composer auto-detecting the correct version to install on PHP 5 since it will complain that your version of PHP does not meet the package requirements. |
Are they different in source? As in, does the php 7 variant not run on php 5? In that case it clearly is a new release that is not backwards compatible, so it would make sense to up the major version number. |
If you consider your library version which uses PHP7 as a "preview" one, and the PHP5 the mainline ( The PHP5 will contain stable releases (tags) and the PHP7 alpha/preview/beta branch will have tags like But what @alcohol said still stands: if the PHP7 version won't work in PHP5, that's a BC break, so a new major version is justified. |
Following semver.org yeah I would say you need a 1.0 branch to maintain PHP5 compat for a while and then bump master to be 2.0 and move on from there. |
Originally @ralt and I were discussing a PHP 7 version that had the same API. The code in the PHP 7 branch would not be PHP 5 compatible, but a user could upgrade to the PHP 7 version without changing any of the code using the library. Still, a major version bump for the PHP 7 branch makes the most sense. Composer already will install previous minor versions if the current version is not compatible with the installed version of PHP. Would it be possible and sensible to have Composer move back to a previous major version as well? That is, if a user ran |
Isn't that what Composer would do anyway provided a laxed constraint, like |
I was referring to a user installing a package for the first time by typing Just trying to make it as easy for users as possible. Of course the docs would make it clear that PHP 5 is supported by the older version, but sometimes users overlook such information. |
Throwing this out there: what happens when you use |
Then the lowest compatible versions of all packages are installed, not exactly ideal and it doesn't really address the problem at hand: initial installation of a package. |
Can you show us the composer.json of the respective versions/branches? Are they on github by any chance? |
I quickly put together an example on GitHub of the schema I'm talking about at https://github.com/trowski/composer-test and added this repo to Packagist as When I run
Changing the command to |
Well, ok I understand your issue. But in my humble opinion, it makes sense that composer does not really know what to do at this point. It shouldn't just pick a lower version simply because your current system is running php version X. When being ambiguous like this, it makes more sense for composer to just fail because it cannot match the highest available version to your environment. If you know that there is a lower available version that specifically matches your current environment and suits your needs as a package, then you should be explicit in your version requirement. Leaving it wide open means you let composer determine the best version, which will (almost) always be the highest stable version. If composer were to magically resolve it according to your expectations, then that would mean inconsistent behavior, since the same command would result in different versions depending on the environment. That is not desirable behavior. |
Composer will already install different versions depending on environment if it's only a minor version difference. If I were to tag the versions in the example repo with the same major version, such as I was just looking for an elegant solution to maintaining branches targeting different versions of PHP while keeping it simple for users. The solution appears to be tagging the branches with different major versions and just making it very clear in the installation instructions which versions to use depending on the installed version of PHP. Thanks for your help and input! |
On 01/06/2015 18:31, Aaron Piotrowski wrote:
As far as I know this is not the case. Besides, either way will require you to maintain two branches for PHP5 I would not worry about it too much. It'll be a community-wide "pain" |
I stand corrected. I should have tested it again before making that post. I must have made a mistake the first time I tested that scenario that allowed the lower version to be installed.
You're certainly correct, so I should have little reason to worry as most projects will face the same problem. Thanks again! |
I have 4 PHP (5.3, 5.4, 5.5, 5.6) versions on my DEV server (Windows 2012, IIS, PHP Manager) |
Say, I have 2 versions of my library, one on php 5, the other on php 7 (using STH, for example). Both versions have the same features and bug fixes.
How can I handle this with composer? Can I do this with branches somehow? Will tags work correctly? For example, should I have
1.0.0-5
and1.0.0-7
? Do I need different major versions? Upping the major number would mean upping by 2...The text was updated successfully, but these errors were encountered: