Skip to content

Commit ebeb045

Browse files
committed
chore: release v1.11.0 — exec, run, ls-remote, resolve, unload, cache clear, tab completion, --no-use flag
1 parent 4231327 commit ebeb045

4 files changed

Lines changed: 765 additions & 120 deletions

File tree

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,39 @@
22

33
## [Unreleased]
44

5+
## [v1.11.0](https://github.com/Thavarshan/phpvm/compare/v1.10.0...v1.11.0) - 2026-04-13
6+
7+
### Added
8+
9+
- **`exec` command:** Run a command with a specific PHP version without globally switching. Executes in a subshell to isolate PATH changes from the current shell. Usage: `phpvm exec <version> <command> [args...]`.
10+
- **`run` command:** Sugar for `phpvm exec <version> php <script>`. Usage: `phpvm run <version> [script] [args...]`.
11+
- **`ls-remote` command:** List available PHP versions from system package manager repositories (Homebrew, apt, dnf, yum, pacman). Supports optional pattern filtering (e.g., `phpvm ls-remote 8.2`).
12+
- **`resolve` command:** Resolve a version descriptor, alias, or keyword to a locally installed version number. Usage: `phpvm resolve <version|alias|keyword>`.
13+
- **`unload` command:** Remove phpvm from the current shell session — deactivates, removes cd hooks, unsets all phpvm functions and variables. Only works when sourced (matches nvm behaviour).
14+
- **`cache clear` command:** Clear the phpvm cache directory. Replaces the previous stub.
15+
- **`--no-use` flag on source:** `source phpvm.sh --no-use` loads functions without auto-switching or registering the cd hook. Useful for lazy-loading setups.
16+
- **Bash tab completion:** New `completions/phpvm.bash` file with context-aware completions for commands, installed versions, and alias names. Auto-sourced when phpvm is loaded.
17+
- **Auto-set `default` alias on first install:** When no `default` alias exists, the first `phpvm install` automatically sets it (matches nvm behaviour).
18+
- **`PHPVM_BIN` export:** After every version switch, `PHPVM_BIN` is exported with the active PHP binary directory. Unset on deactivate.
19+
- **XDG_CONFIG_HOME fallback:** `PHPVM_DIR` now respects `$XDG_CONFIG_HOME/phpvm` when `XDG_CONFIG_HOME` is set and `PHPVM_DIR` is not.
20+
21+
### Fixed
22+
23+
- **`hash -r` after version switch:** Added `command hash -r` to `switch_to_version_php()`, `switch_to_system_php()`, and `phpvm_deactivate()` to invalidate the bash command hash table. Prevents stale binary resolution after switching versions.
24+
- **`phpvm_current` uses `printf` instead of `echo`:** Consistent with project conventions; avoids potential `-n`/`-e` misinterpretation.
25+
- **Auto-default alias works in test mode:** The auto-default alias logic now fires for both real and mock installations.
26+
27+
### Changed
28+
29+
- **`list` output formatting:** Active version is marked with a `->` arrow prefix and green colouring. Versions matching the `default` alias show a `(default)` annotation.
30+
- **Help text updated:** Removed "Planned Features" section; all commands now shown as implemented with examples.
31+
32+
### Internal
33+
34+
- **Version bump:** Updated to v1.11.0.
35+
- **New tests:** 30 BATS tests covering exec, run, ls-remote, resolve, cache clear, list formatting, auto-default alias, and help text. Replaced 5 obsolete stub tests.
36+
- **All tests passing:** 78 BATS tests pass.
37+
538
## [v1.10.0](https://github.com/Thavarshan/phpvm/compare/v1.9.4...v1.10.0) - 2026-03-28
639

740
### Added

completions/phpvm.bash

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/env bash
2+
# Bash/Zsh tab completion for phpvm
3+
# Source this file or place it in your completions directory
4+
5+
_phpvm_completions() {
6+
local cur prev commands
7+
cur="${COMP_WORDS[COMP_CWORD]}"
8+
prev="${COMP_WORDS[COMP_CWORD - 1]}"
9+
10+
commands="install uninstall use current which list ls ls-remote alias unalias exec run resolve cache deactivate system auto info version help unload"
11+
12+
case "$prev" in
13+
use | uninstall | which | exec | run | resolve)
14+
# Complete with installed versions + aliases
15+
local versions=""
16+
local phpvm_dir="${PHPVM_DIR:-$HOME/.phpvm}"
17+
18+
# Installed versions from active_version tracking
19+
if [ -d "$phpvm_dir/alias" ]; then
20+
local alias_file
21+
for alias_file in "$phpvm_dir/alias"/*; do
22+
[ -f "$alias_file" ] && versions="$versions ${alias_file##*/}"
23+
done
24+
fi
25+
26+
# Try to get installed versions from package manager
27+
if command -v brew > /dev/null 2>&1; then
28+
local formula
29+
while IFS= read -r formula; do
30+
local ver="${formula#php@}"
31+
[ "$formula" = "php" ] && continue
32+
versions="$versions $ver"
33+
done < <(brew list --formula 2> /dev/null | command grep -E '^php(@[0-9]+\.[0-9]+)?$')
34+
fi
35+
36+
versions="$versions system"
37+
# shellcheck disable=SC2207 # Intentional: word splitting for COMPREPLY
38+
COMPREPLY=($(compgen -W "$versions" -- "$cur"))
39+
return
40+
;;
41+
alias)
42+
# Complete with alias subcommands or existing aliases
43+
if [ "$COMP_CWORD" -eq 2 ]; then
44+
# shellcheck disable=SC2207
45+
COMPREPLY=($(compgen -W "default" -- "$cur"))
46+
fi
47+
return
48+
;;
49+
unalias)
50+
# Complete with existing alias names
51+
local aliases=""
52+
local phpvm_dir="${PHPVM_DIR:-$HOME/.phpvm}"
53+
if [ -d "$phpvm_dir/alias" ]; then
54+
local alias_file
55+
for alias_file in "$phpvm_dir/alias"/*; do
56+
[ -f "$alias_file" ] && aliases="$aliases ${alias_file##*/}"
57+
done
58+
fi
59+
# shellcheck disable=SC2207
60+
COMPREPLY=($(compgen -W "$aliases" -- "$cur"))
61+
return
62+
;;
63+
cache)
64+
# shellcheck disable=SC2207
65+
COMPREPLY=($(compgen -W "clear" -- "$cur"))
66+
return
67+
;;
68+
phpvm)
69+
# shellcheck disable=SC2207
70+
COMPREPLY=($(compgen -W "$commands" -- "$cur"))
71+
return
72+
;;
73+
esac
74+
75+
# Default: complete commands
76+
# shellcheck disable=SC2207
77+
COMPREPLY=($(compgen -W "$commands" -- "$cur"))
78+
}
79+
80+
complete -F _phpvm_completions phpvm

0 commit comments

Comments
 (0)