1515
1616``` sh
1717$ phpvm use 8.2
18- Now using PHP v8.2.10
18+ Switching to PHP 8.2...
19+ Switched to PHP 8.2.
1920$ php -v
2021PHP 8.2.10
2122$ phpvm use 8.1
22- Now using PHP v8.1.13
23+ Switching to PHP 8.1...
24+ Switched to PHP 8.1.
2325$ php -v
2426PHP 8.1.13
2527```
@@ -31,8 +33,10 @@ PHP 8.1.13
3133- Auto-switch PHP versions based on project ` .phpvmrc ` .
3234- Supports macOS (via Homebrew) and Linux distributions.
3335- Works with common shells (` bash ` , ` zsh ` ).
34- - Improved error handling and informative, color-coded feedback.
36+ - Improved error handling with detailed messages and suggestions.
37+ - Informative, color-coded feedback with timestamps for logs.
3538- Includes unit tests with BATS for automated testing.
39+ - Helper functions for better maintainability and reduced code duplication.
3640
3741## Installation
3842
@@ -52,7 +56,8 @@ This script will download and set up `phpvm` in `~/.phpvm` and automatically upd
5256
5357``` sh
5458export PHPVM_DIR=" $HOME /.phpvm"
55- source " $PHPVM_DIR /phpvm.sh"
59+ export PATH=" $PHPVM_DIR /bin:$PATH "
60+ [ -s " $PHPVM_DIR /phpvm.sh" ] && . " $PHPVM_DIR /phpvm.sh"
5661```
5762
5863### Verify Installation
@@ -83,6 +88,12 @@ To switch between installed versions:
8388phpvm use 8.0
8489```
8590
91+ To switch back to the system PHP version:
92+
93+ ``` sh
94+ phpvm system
95+ ```
96+
8697Verify the active version with:
8798
8899``` sh
@@ -97,24 +108,34 @@ Create a `.phpvmrc` file in your project directory to specify the desired PHP ve
97108echo " 8.1" > .phpvmrc
98109```
99110
100- When you navigate to that project directory, ` phpvm ` will automatically switch to PHP 8.1.
101-
102- ### Uninstalling PHP Versions
103-
104- To uninstall a specific PHP version:
111+ When you navigate to that project directory and run:
105112
106113``` sh
107- phpvm uninstall 7.4
114+ phpvm auto
108115```
109116
117+ phpvm will automatically detect and switch to the version specified in the ` .phpvmrc ` file.
118+
110119### Listing Installed Versions
111120
112- To list installed PHP versions:
121+ To list all installed PHP versions:
113122
114123``` sh
115124phpvm list
116125```
117126
127+ This will show all installed PHP versions and indicate the currently active one.
128+
129+ ### Running Self-Tests
130+
131+ phpvm includes built-in self-tests to verify everything is working correctly:
132+
133+ ``` sh
134+ phpvm test
135+ ```
136+
137+ This will run a series of tests on your system to ensure all phpvm functions are working properly.
138+
118139## Uninstallation
119140
120141To completely remove ` phpvm ` , run:
@@ -127,23 +148,57 @@ Then remove the following lines from your shell profile (`~/.bashrc`, `~/.zshrc`
127148
128149``` sh
129150export PHPVM_DIR=" $HOME /.phpvm"
130- source " $PHPVM_DIR /phpvm.sh"
151+ export PATH=" $PHPVM_DIR /bin:$PATH "
152+ [ -s " $PHPVM_DIR /phpvm.sh" ] && . " $PHPVM_DIR /phpvm.sh"
131153```
132154
133155## Troubleshooting
134156
135157If you experience issues with ` phpvm ` , try the following:
136158
137- - Ensure your shell profile is sourcing ` phpvm.sh ` .
138- - Restart your terminal after installing or updating.
139- - Verify that Homebrew is installed (for macOS users).
140- - Check for permission issues during the installation or PHP version switching process.
141- - Refer to the [ Changelog] ( ./CHANGELOG.md ) for recent updates and fixes.
159+ - Run ` phpvm test ` to verify all functions are working correctly
160+ - Ensure your shell profile is sourcing ` phpvm.sh `
161+ - Restart your terminal after installing or updating
162+ - Verify that the required package manager is installed:
163+ - Homebrew for macOS
164+ - apt, dnf, yum, or pacman for Linux
165+ - Check for permission issues during the installation or PHP version switching process
166+ - For Linux systems, you may need to use ` sudo ` for installation and switching
167+ - Refer to the [ Changelog] ( ./CHANGELOG.md ) for recent updates and fixes
142168
143169## Development & Testing
144170
145171- This project includes a set of BATS unit tests located in the repository (e.g., ` test_phpvm.bats ` ).
146172- Contributions, bug reports, and feature requests are welcome.
173+ - The codebase now includes helper functions for better maintainability and reduced duplication.
174+
175+ ### Testing
176+
177+ phpvm includes built-in self-tests that validate all core functionality:
178+
179+ ``` sh
180+ # Run the built-in tests
181+ phpvm test
182+ ```
183+
184+ The test framework verifies:
185+
186+ - Output and formatting functions
187+ - System detection
188+ - PHP version installation (mocked)
189+ - Version switching
190+ - Auto-switching based on .phpvmrc
191+ - System PHP integration
192+
193+ These tests can be run in any environment with a shell and don't require external testing frameworks.
194+
195+ ### Debugging
196+
197+ To enable debug output, set the ` DEBUG ` environment variable to ` true ` :
198+
199+ ``` sh
200+ DEBUG=true phpvm install 8.1
201+ ```
147202
148203## Maintainers
149204
0 commit comments