Add PHP binary discovery and selection for project creation - #1306
Draft
Soner (shyim) wants to merge 1 commit into
Draft
Add PHP binary discovery and selection for project creation#1306Soner (shyim) wants to merge 1 commit into
Soner (shyim) wants to merge 1 commit into
Conversation
…project create For local (non-Docker) project creation, discover the usable PHP executables installed on the machine (PHP_BINARY, PATH including versioned names, and platform locations such as Homebrew, versioned system packages, and common Windows installs), let an interactive user pick one that satisfies the chosen Shopware release's PHP constraint, use that exact binary for dependency validation and the Composer install, and persist its absolute path as php_binary in the generated .shopware-project.yml. - internal/system: new PHP discovery service (canonicalizes, de-duplicates, probes versions, ignores broken executables, sorts newest first while keeping PHP_BINARY first) plus helpers for filtering by constraint and picking the preferred candidate - project create: new --php-binary flag for non-interactive selection (rejected together with --docker), interactive select prompt after the Shopware version is resolved, deterministic non-interactive fallback (compatible PHP_BINARY, then the compatible PATH default, otherwise a clear error listing compatible installations), and a rendered list of discovered installations when none satisfies the constraint - shop config: optional root-level php_binary field, exposed through project config-schema; Docker projects never prompt for or write it - executor: LocalExecutor routes console/PHP/Composer commands through the precedence php_binary > PHP_BINARY > php from PATH, so the persisted selection applies to later project commands too - dependency validation can now check a specific PHP binary instead of only the ambient one Existing projects without php_binary keep the exact previous behavior. Fixes #1303 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xd8qd8PT9pjFvBDrvMoJ1L
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1306 +/- ##
==========================================
+ Coverage 54.00% 54.34% +0.33%
==========================================
Files 303 305 +2
Lines 23453 23697 +244
==========================================
+ Hits 12666 12878 +212
- Misses 10759 10790 +31
- Partials 28 29 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changed?
Added comprehensive PHP executable discovery and selection capabilities to the project creation workflow:
New PHP discovery system (
internal/system/php_discovery.go):DiscoverPHPInstallations()finds all usable PHP executables on the machine from multiple sources:PHP_BINARYenvironment variable, PATH (including versioned names likephp8.3), and platform-specific locations (Homebrew on macOS, system packages on Linux, XAMPP/Laragon on Windows)PHP_BINARYfirst, then by version (newest first)Project creation PHP selection (
cmd/project/project_create_php.go):--php-binaryflag to explicitly select a PHP executable for project creationPHP_BINARYenv var, then PATH default, then newest versionConfig persistence (
internal/shop/config.go):PHPBinaryfield to project config, persisted asphp_binaryin.shopware-project.ymlphp_binaryconfig (if set) for all PHP commands, falling back toPHP_BINARYenv var orphpfrom PATHDependency validation updates (
internal/system/setup.go):CheckProjectDependencies()now accepts optionalphpBinaryparameter to check a specific PHP executableExecutor improvements (
internal/executor/local.go):LocalExecutornow respects project's selected PHP binaryWhy?
This enables developers to:
How was this tested?
internal/system/php_discovery_test.go): candidate collection, deduplication, version probing, sorting, filteringcmd/project/project_create_php_test.go): explicit flag handling, interactive/non-interactive fallbacks, constraint validationinternal/shop/config_test.go)internal/executor/executor_test.go)GetInstalledPHPVersion()to use newGetPHPVersionOfBinary()with improved version parsing and timeout handlingRelated issue or discussion
Enables proper PHP version management for multi-version development environments.
https://claude.ai/code/session_01Xd8qd8PT9pjFvBDrvMoJ1L