Add PHP binary path override - #41
Conversation
|
📋 PR Summary This PR adds a Changes
|
| return nil, source, "", errors.Wrapf(err, "invalid %s", PHPBinaryPathEnvVar) | ||
| } | ||
| selected = s.versions[s.addVersion(selected)] | ||
| s.sortVersions() |
There was a problem hiding this comment.
🟡 Warning — Concurrent override calls can fatally panic, and every call redundantly re-execs and re-sorts.
The SYMFONY_CLI_PHP_BINARY_PATH branch turns BestVersionForDir — otherwise a read-only query — into a writer: s.addVersion(selected) appends to s.versions and s.sortVersions() rebuilds the s.seen map (re-evalSymlinks-ing every entry) on every call, and discoverPHPPath re-execs php --version each time. Two side effects follow: every invocation with the override set repeats the exec and full re-sort, and if two goroutines call BestVersionForDir with the override active the unsynchronized writes to s.seen can trigger Go's fatal "concurrent map writes" panic (the non-override paths never mutate this map).
| binName = binName[:len(binName)-len(extension)] | ||
| } | ||
| discoverCompanions = strings.Contains(binName, "php") | ||
| } else if filepath.Base(dir) == "bin" { |
There was a problem hiding this comment.
🔵 Info — Override of non-standard PHP layouts drops FPM/CGI server support.
On non-Windows, companion (FPM/CGI/config) discovery is enabled only when the resolved binary's parent directory is literally named bin (filepath.Base(dir) == "bin"). An override pointing at a custom-built PHP whose CLI binary is not under a bin/ directory (e.g. /opt/php8.4/php) is reported as a CLI-only installation with empty FPMPath/CGIPath even when a php-fpm/php-cgi sits alongside it, so the override silently loses FPM/CGI capability for such layouts.
Closes symfony-cli/symfony-cli#599