You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`phpvm install [version]`| Install a PHP version (reads `.phpvmrc` if no version given)|
101
+
|`phpvm use [version]`| Switch PHP version (reads `.phpvmrc` → default alias if no version given)|
102
+
|`phpvm uninstall <version>`| Remove a specific PHP version |
103
+
|`phpvm current`| Display the currently active PHP version |
104
+
|`phpvm which [version]`| Show the path to PHP binary for a version |
105
+
|`phpvm deactivate`| Temporarily disable phpvm and restore PATH |
106
+
|`phpvm system`| Switch to system/Homebrew default PHP |
107
+
|`phpvm auto`| Auto-switch based on `.phpvmrc` file |
108
+
|`phpvm list` or `phpvm ls`| List all installed PHP versions |
109
+
|`phpvm alias [name] [ver]`| Create, update, or list version aliases |
110
+
|`phpvm unalias <name>`| Remove version alias |
111
+
|`phpvm cache dir`| Show phpvm cache directory |
112
+
|`phpvm info`| Show system information for debugging |
113
+
|`phpvm version`| Show version information |
114
+
|`phpvm --version` / `-v`| Show version information (aliases) |
115
+
|`phpvm help`| Show help message |
115
116
116
117
### Installing PHP Versions
117
118
@@ -197,13 +198,28 @@ Create a `.phpvmrc` file in your project directory to specify the desired PHP ve
197
198
echo"8.1"> .phpvmrc
198
199
```
199
200
200
-
When you navigate to that project directory and run:
201
+
**Automatic switching on `cd`**: When phpvm is sourced into your shell, it registers a cd hook that detects `.phpvmrc` files and switches PHP versions automatically as you navigate between directories. No manual command needed — just `cd` into a project.
202
+
203
+
-**Bash**: Uses `PROMPT_COMMAND`
204
+
-**Zsh**: Uses `chpwd_functions`
205
+
- Gated behind `PHPVM_AUTO_USE=true` (the default)
206
+
- Skips switching if already on the correct version
207
+
208
+
**Using `use` and `install` without a version**: When no version argument is given, these commands read `.phpvmrc` automatically:
201
209
202
210
```sh
203
-
phpvm auto
211
+
# Reads version from .phpvmrc in current or parent directories
212
+
phpvm use
213
+
phpvm install
204
214
```
205
215
206
-
phpvm will automatically detect and switch to the version specified in the `.phpvmrc` file.
216
+
`phpvm use` follows this fallback chain: `.phpvmrc` → `default` alias → error.
217
+
218
+
**Manual switching**: You can also trigger auto-switching explicitly:
219
+
220
+
```sh
221
+
phpvm auto
222
+
```
207
223
208
224
Aliases can also be used in `.phpvmrc`:
209
225
@@ -320,14 +336,14 @@ fi
320
336
321
337
## Environment Variables
322
338
323
-
| Variable | Default | Description |
324
-
| --- | --- | --- |
325
-
|`PHPVM_DIR`|`~/.phpvm`| Installation directory |
326
-
|`PHPVM_AUTO_USE`|`true`| Enable automatic `.phpvmrc` detection when sourced |
327
-
|`PHPVM_PHPVMRC_MAX_DEPTH`|`25`| Max parent directories to traverse when searching for `.phpvmrc`|
328
-
|`DEBUG`|`false`| Enable debug logging with timestamps |
329
-
|`NO_COLOR`|_(unset)_| Disable color output ([no-color.org](https://no-color.org/)) |
330
-
|`PHPVM_LOG_TIMESTAMPS`|`false`| Always show timestamps in log output |
0 commit comments