production icon indicating copy to clipboard operation
production copied to clipboard

Do not override PHP version in composer.json

Open AndreasA opened this issue 3 years ago • 2 comments

I don't think it is a good idea to override the PHP version in the composer.json using config.platform: https://github.com/shopware/production/blob/6.4/composer.json#L8

This way, the composer installation will succeed with PHP 7.2 which otherwise would immediately fail as PHP 7.4 is required. Also it might install wrong dependencies (at least without a lock file).

AndreasA avatar Mar 02 '21 07:03 AndreasA

We use this template also for packging the Installation zip. To ensure that the dependencies are working between lowest php version and highest we always use the lowest php version as platform. . As we use packages that are available in the entire php version range, it makes no really difference.

And as always this is an template. Modify to match your needs :)

shyim avatar Mar 02 '21 08:03 shyim

It is also used for composer project setups and forcing a fix version is wrong there as one could setup the production template using PHP 7.2 now or even 5.6 now.

For pipelines you would need to checkout the template and do all tests etc. with each PHP version to be 100% sure everything works correctly.

For the installations packager, why not run it with the lowest PHP version to ensure that works. However, that does not mean it will work fine with newer PHP versions that requires a separate test.

You could also use ignore-platform-reqs during installation and then run the pipelines with everything else. You have the composer.lock in the project after all. Another solution would be to run composer config ... in the installation package pipeline, so this is not part of the composer.json but added when needed.

Regarding custom template, I don't want to create a fork because I would need to re-apply any changes you make for all necessary Shopware versions that I might use.

That is too much effort. However, I wil definitely adjust that value after creating a new project with composer, but I would like to avoid the need for this.

Anyway the template currently does not support PHP 8.x according to require definition which is, of course, ignored due to the platform setting but if I wanted to add it as dependency in a different composer.json, it would fail as that setting is only used in the root composer.json Not that that would make sense but just as example. See also https://github.com/shopware/production/issues/91

AndreasA avatar Mar 02 '21 11:03 AndreasA

The new template doesn't have override anymore https://github.com/shopware/production/blob/flex/composer.json

shyim avatar Oct 25 '22 07:10 shyim