Isolate Composer under ~/.pv/composer#12
Merged
munezaclovis merged 2 commits intomainfrom Mar 5, 2026
Merged
Conversation
- Add ComposerDir, ComposerCacheDir, ComposerBinDir, ComposerPharPath helpers - Save composer.phar to ~/.pv/data/ instead of ~/.pv/bin/ - Replace ~/.pv/bin/composer binary with a shim that sets COMPOSER_HOME and COMPOSER_CACHE_DIR, resolves PHP version per-project, then execs the phar through the resolved PHP binary - Include ~/.pv/composer/vendor/bin in PATH instructions so composer global require binaries are immediately available - Pass COMPOSER_HOME and COMPOSER_CACHE_DIR in CaddyEnv so FrankenPHP worker processes inherit them (Statamic, Nova, etc.) - Add composer isolation check to selftest (composer config --global home) - Add migration helper that copies auth.json and config.json from ~/.composer if they exist - Add 13 e2e tests covering env isolation, arg forwarding, version resolution (.pv-php, composer.json, global), error cases, and override of external COMPOSER_HOME
- Add scripts/e2e/composer.sh: real composer global require/remove cycle that verifies packages land in ~/.pv/composer/vendor/bin and ~/.composer is never created - Update verify-install.sh to check composer shim, phar, and directories - Update diagnostics.sh to dump composer dir/shim on failure - Wire Phase 12 (Composer Containment) into e2e.yml 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.
Summary
~/.pv/composer/— it never touches~/.composer~/.pv/bin/composeris a shim script (like the PHP shim) that setsCOMPOSER_HOMEandCOMPOSER_CACHE_DIR, resolves the correct PHP version per-project, then execs the pharcomposer global require laravel/installerinstalls to~/.pv/composer/vendor/bin/, which is now included in the PATH instructionsCOMPOSER_HOME/COMPOSER_CACHE_DIRviaCaddyEnv()so runtime Composer calls (Statamic, Nova) are also isolatedcomposer config --global homereturns the pv-managed directory~/.composer/auth.jsonandconfig.jsonare automatically migrated duringpv installWhat changed
config/paths.goComposerDir,ComposerCacheDir,ComposerBinDir,ComposerPharPath; create dirs inEnsureDirs; add env vars toCaddyEnvbinaries/install.gocomposer.pharto~/.pv/data/instead of~/.pv/bin/phpenv/shim.gocomposerShimScript;WriteShims()now writes both php and composer shimssetup/shell.go~/.pv/composer/vendor/binsetup/selftest.gocheckComposerIsolation()to verifyCOMPOSER_HOMEsetup/composer.goMigrateComposerConfig()copies auth/config from~/.composercmd/install.goTest plan
go test ./...)composer_e2e_test.gothat invoke the real shim with a fake PHP binary:COMPOSER_HOMEandCOMPOSER_CACHE_DIRare set correctlycomposer.pharpath is passed as first arg to PHPglobal require laravel/installer --dev).pv-php, andcomposer.json~/.composeris never touchedCOMPOSER_HOMEenv is overridden by the shimCaddyEnventries