Auto-manage Laravel installer PHAR#42
Merged
munezaclovis merged 13 commits intomainfrom Mar 13, 2026
Merged
Conversation
Introduces internal/packages with the Package type, Managed registry (laravel/installer), and path helpers PharPath(), SymlinkPath(), and LatestReleaseURL().
laravel/installer has never published PHAR assets on GitHub releases. Add dual install method support: MethodComposer (via composer global require) and MethodPHAR (via GitHub release download). Laravel installer now uses MethodComposer, landing the binary at ~/.pv/composer/vendor/bin/ which is already on PATH via pv env. PHAR infrastructure remains for future packages like phpstan and psalm.
- Thread context.Context through Install/Update/composer functions so the background updater respects shutdown signals (no more 30s hangs) - Use exec.CommandContext for composer child processes (no orphans) - Use http.NewRequestWithContext for GitHub API calls - Log background updater failures to stderr instead of swallowing - Context-aware retry delay (select on ctx.Done vs time.After) - Track package install failures in cmd/install.go (exit non-zero) - Fix os.Remove to only ignore ErrNotExist, not all errors - Include GitHub response body in non-200 error messages - Limit io.ReadAll to 1MB on GitHub API responses - Make switch statements exhaustive (explicit MethodPHAR + error default) - Wrap composer exec errors with %w to preserve exit code info - Add Package.Validate() with init() check for registry correctness - Guard against empty GitHub release tags - Improve comment accuracy (Update docs, version field docs)
composer global update does nothing if the package was never added to the global composer.json. Switch to composer global require which is idempotent — installs if missing, updates if already present. This fixes the E2E failure where composer show failed because the package had never been installed.
CombinedOutput() mixed stderr warnings (e.g. "Changed current directory to...") into stdout, corrupting JSON output from composer global show --format=json. Now capture stdout and stderr separately: return stdout-only on success for clean JSON, combine them on error for diagnostics.
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
internal/packages/module that downloads, installs, and auto-updates managed PHAR packages (starting withlaravel/installer)~/.pv/internal/packages/, symlinked into~/.pv/bin/, with versions tracked inversions.jsonpv install(per-package progress bar),pv update(per-package status), andserver.Start()(background goroutine with context-based shutdown)Test Plan
go test ./internal/packages/ -v— 10 tests covering install, update, version normalization, background updater lifecyclego test ./internal/config/ -run TestPackagesDir -v— PackagesDir path helpergo test ./... -timeout 60s— full suite passes (no regressions)go vet ./...andgofmt -l .— cleanpv installshows✓ laravel v*steppv updateshows✓ laravel already up to dateor✓ laravel updated to v*