Use symfony CLI for running PHP when available #311
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Right now there is no easy way to choose a PHP version / installation for use by shopware-cli. This can be a problem when working on multiple projects with different required PHP versions.
Symfony's CLI tool can automatically detect the correct PHP version / installation to use for a project based on (among other things) a .php-version file or the required PHP version from composer.json files.
This PHP version can than be used by running
symfony php
instead ofphp
. Similarly there is also asymfony composer
command for running composer with the correct PHP version and even asymfony console
command for running thebin/console
tool.We can use this to easily support different PHP versions.
This PR introduces a new
internal/phpexec
package for creating commands for running PHP, composer and bin/console which will automatically use the Symfony CLI if available.It also updates the existing code to use the new package whenever possible.
The new logic can be disable by setting the
SHOPWARE_CLI_NO_SYMFONY_CLI
environment variable to1
.While it would also have been possible to directly import the logic from the symfony-cli repository (which is also written in Go), doing so would be more work as the logic is not in one place and it may end up introducing incompatibilities between the two implementations.
Also unlike the actual CLI interface (
symfony php
, etc.) the actual source packages are not guaranteed to be stable.