Releases: Thavarshan/phpvm
v1.4.0
Added
-
Uninstall Command: New
phpvm uninstall <version>
command to remove installed PHP versions- Supports all package managers: Homebrew, APT, DNF, YUM, Pacman
- Automatically detects installed packages before attempting removal
- Smart cleanup of symlinks and active version when uninstalling currently active PHP
- Includes comprehensive test mode support with mock package databases
- Provides clear warnings when attempting to uninstall non-existent versions
-
Enhanced Shell Integration: Improved sourcing support with automatic .phpvmrc detection
- Sets
PHPVM_FUNCTIONS_LOADED=true
environment variable when sourced - Auto-switches PHP version based on .phpvmrc when script is sourced (configurable via
PHPVM_AUTO_USE
) - Better function availability detection for shell integration
- Sets
-
Advanced Execution Control: New
PHPVM_SOURCED
environment variable for explicit execution control- Supports
true/1/yes
to force sourcing mode - Supports
false/0/no
to force execution mode - Provides override mechanism for edge cases and automation
- Supports
Changes
-
Robust POSIX Compliance: Complete rewrite of execution detection logic
- Replaced bash-specific
[[ "${BASH_SOURCE[0]}" == "${0}" ]]
with 3-layer POSIX detection - Layer 1: Explicit override via
PHPVM_SOURCED
environment variable - Layer 2: Test mode detection (
PHPVM_TEST_MODE
) - Layer 3: POSIX-compliant return test
(return 0 2>/dev/null)
- Now works reliably on Ubuntu/Mint systems using dash shell (
/bin/sh
)
- Replaced bash-specific
-
Enhanced Error Handling: Improved function validation and debugging
- Added function existence checks before execution
- Better error messages with script corruption detection
- Enhanced debug logging throughout execution flow
-
Improved Test Infrastructure: Extended mock system for uninstall testing
- Package manager-specific mock directories for test mode
- Better package detection simulation across different systems
- More comprehensive test coverage for edge cases
Fixed
-
Ubuntu/Mint Compatibility: Resolved "Bad substitution" errors on systems using dash shell
- Issue occurred when
/bin/sh
pointed to dash instead of bash - Script now fully POSIX-compliant and works across all Unix-like systems
- No more dependency on bash-specific features
- Issue occurred when
-
Shell Sourcing Reliability: Fixed inconsistent behavior when sourcing script
- Improved detection of sourced vs executed context
- Better handling of edge cases in different shell environments
- More predictable behavior across bash, dash, zsh, and other POSIX shells
-
Package Manager Detection: Enhanced validation for uninstall operations
- Better regex patterns for package detection across different package managers
- Improved error handling for package manager-specific commands
- More accurate installed package verification before removal attempts
v1.3.0
Added
- Added
system
command to easily switch back to system PHP version - Added timestamps to all log messages for better traceability and debugging
- Added log levels (INFO, ERROR, WARNING, DEBUG) for more structured logging
- Added
run_with_sudo
helper function to centralize sudo usage logic - Added comprehensive self-tests with
phpvm test
command - Added test for corrupted
.phpvmrc
file handling - Added better support for detecting and using latest PHP version from Homebrew
- Added improved error messages with more detailed information
- Added ability to run self-tests with
phpvm test
command - Added debugging capability via
DEBUG=true
environment variable
Changed
- Changed logging format to include timestamps and log levels
- Changed sudo handling to use a centralized helper function
- Changed path expansion to use
$HOME
instead of tilde notation for better compatibility - Changed error handling to provide more descriptive and actionable messages
- Changed test framework to be integrated directly into the script
- Changed help message to include information about the
test
command - Improved bash/zsh shell compatibility with better sourcing logic
- Improved code organization and reduced duplication with helper functions
Fixed
- Fixed shell crash issue when sourcing in zsh with p10k theme
- Fixed path expansion issues in Ubuntu bashrc configurations
- Fixed missing system PHP switching functionality on macOS
- Fixed detection of latest PHP version on macOS when installed via Homebrew's generic 'php' formula
- Fixed potential sudo permission issues on Linux by using
run_with_sudo
consistently - Fixed auto-switching edge case with invalid or corrupted
.phpvmrc
files - Fixed script execution issues when sourced from shell initialization files
- Fixed various edge cases in version detection and switching
Full Changelog: 1.2.0...1.3.0
v1.2.0
Added
- GitHub Actions CI/CD Integration: Added workflows for running automated tests and verifying PHPVM functionality on macOS and Linux.
- Linux Compatibility: Implemented Homebrew mock support to allow testing on both macOS and Linux environments.
- Extended Test Suite: Improved BATS test coverage to handle different system environments and dependencies.
Changed
- Improved Homebrew Detection: The script now properly checks for Homebrew availability and handles missing installations more gracefully.
- Refactored Test Setup: The
setup
function intest_phpvm.bats
now ensures correct sourcing ofphpvm.sh
and mocks Homebrew on Linux. - Better Error Messages: Adjusted error outputs for clarity when Homebrew or PHP versions are unavailable.
Fixed
- Fixed Ubuntu Compatibility Issues: The tests no longer fail due to missing Homebrew; instead, they mock Homebrew behavior on Linux.
- Resolved Test Failures: The
install_php
,use_php_version
, andauto_switch_php_version
tests now properly execute across different OS platforms. - Prevented Test Cleanup Failures: The
teardown
function now ensures.phpvmrc
and other temporary files are removed only if they exist.
Full Changelog: 1.1.0...1.2.0
v1.1.0
Added
- Added comprehensive error handling to the main phpvm script for robust operations.
- Added checks for command availability (e.g., curl) in the installation script.
- Added a suite of unit tests using BATS, allowing automated testing of core functionalities.
- Added clear and informative, color-coded terminal messages for user interactions.
Changed
- Enhanced the installation script to safely modify user shell profiles and avoid duplicate entries.
- Updated the main phpvm script to use strict mode (
set -euo pipefail
) for improved reliability. - Improved overall error reporting to capture and relay issues during directory creation, downloading, and file permission changes.
Fixed
- Fixed various shellcheck warnings/errors such as SC2034 (unused variables), SC2086 (unquoted variables), SC2155 (variable declaration), and SC2128 (array handling).
- Fixed potential issues with word splitting and globbing by ensuring proper quoting of variables in command calls.
Full Changelog: 1.0.0...1.1.0
v1.0.0
Added
- Auto-switching PHP versions based on
.phpvmrc
. - Improved support for macOS Homebrew installations.
- Enhanced installation script for easy setup using
curl
orwget
. - More robust error handling and output formatting.
- Extended compatibility with
bash
andzsh
shells.
Fixed
- Resolved issues with Homebrew PHP detection on macOS.
- Prevented terminal crashes due to incorrect sourcing in shell startup scripts.
- Improved handling of missing PHP versions.
Full Changelog: 0.0.1...1.0.0
v0.0.1
Initial release.