Sprint 4: Linux .phpvmrc auto-switch (1.6.5)#8
Merged
Conversation
Mirror the Windows .phpvmrc / phpvm auto / phpvm hook surface on
bash and zsh. Same .phpvmrc file format - portable across OS.
New commands
- phpvm auto Resolve .phpvmrc upstream and switch
$PATH for the current shell only.
- phpvm hook enable Write $PHPVM_DIR/.auto-hook flag.
- phpvm hook disable Remove the flag.
- phpvm hook status Report whether the hook is enabled.
Hook mechanism
- phpvm.sh is already sourced into the user's rc, so we just check
the flag file at source time and register the appropriate hook:
* zsh: add-zsh-hook chpwd _phpvm_auto (fires on every cd)
* bash: prepend `_phpvm_auto -s` to $PROMPT_COMMAND (fires per
prompt, idempotent)
- A new PHPVM_NO_INIT=1 guard at the bottom of the file lets bats
tests source the script without triggering side effects.
Helpers (all offline)
- _phpvm_find_rc walks from $1 (default $PWD) up to /.
- _phpvm_read_rc strips #-comments, trims, drops leading `v`.
- _phpvm_resolve_rc passes installed semver through; partial
major.minor picks the highest installed patch.
- _phpvm_auto tracks active in $PHPVM_AUTO_ACTIVE so repeat calls
no-op and leaving a project removes the prepend.
Behaviour matches Windows exactly: missing version warns + install
hint, never auto-installs.
Tests
- 21 bats-core tests under tests/linux/auto.bats covering find /
read / resolve / auto state machine / hook flag toggling.
- CI ubuntu-latest now installs bats and runs them after shellcheck.
- Windows 40 Pester tests still pass.
Docs
- README gets a Linux Auto-Switch section parallel to the Windows
one, with the shell-specific mechanism table.
Audit (S4.7 stretch)
- Captured Windows-only commands missing from Linux as B14/B15/B16
in ROADMAP backlog: composer, fix-ini, ext laravel preset.
Bump version 1.6.0 -> 1.6.5.
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
Mirror the Windows
.phpvmrcfeature on bash/zsh — same file format, same semantics, same warn-only-on-missing behaviour. Closes the platform gap introduced in 1.6.0.phpvm auto— one-shot switch by walking up from$PWDlooking for.phpvmrc.phpvm hook enable/disable/status— toggles$PHPVM_DIR/.auto-hook. Becausephpvm.shis already sourced into your rc, the next shell load picks up the flag and registers the appropriate hook (add-zsh-hook chpwdon zsh,PROMPT_COMMANDon bash).PHPVM_NO_INIT=1— guard so tests can source the script without side effects.ubuntu-latestafter shellcheck.Test plan
phpvm hook enable, restart shell,cdinto a project with.phpvmrccontaining8.3->php -vshows the latest installed 8.3 patch.cdto an unrelated dir -> auto prepend cleared.phpvm hook disable, restart shell,cdno longer triggers auto..phpvmrcportability: same file works unchanged on Windows + Linux.Out of scope (deferred to backlog)
Surfaced by the parity audit (S4.7) and captured in ROADMAP backlog:
phpvm composeron Linuxphpvm fix-inion Linuxphpvm ext laravelpreset on Linux