A simple yet powerful CLI tool to manage multiple PHP versions in XAMPP on Windows.
- π Switch between PHP versions instantly
- π¦ Download and install new PHP versions automatically
- οΏ½οΈ Uninstall PHP versions safely
- οΏ½π List all installed PHP versions (local)
- π Fetch available stable PHP versions from PHP.net (global)
- β‘ Automatic Apache configuration updates
- π‘οΈ Safe backups before switching
Download the latest MSI installer from Releases and run it. The installer will automatically add phat to your PATH.
-
Clone or download from GitHub:
git clone https://github.com/pphatdev/php-version-switcher.git
-
Add the folder to your system PATH:
Settings β System β About β Advanced system settings β Environment Variables β Path β New
Add the full path to where you cloned/extracted the files.
-
Open a new terminal and run:
phat help
Note: Phat is designed for Windows Command Prompt or PowerShell. If using Git Bash or other bash terminals, see the Git Bash compatibility guide.
phat -v
# or
phat --versionDisplays the current Phat version.
phat list
# or explicitly list local versions
phat list --php --localOutput example:
Installed PHP versions:
* 7.4.33 (active, php7)
8.0.30 (8.0.30)
8.2.27 (8.2.27)
phat list --php --globalThis fetches the latest stable PHP versions available from windows.php.net (Thread-Safe x64 builds).
Output example:
Fetching available PHP versions from windows.php.net...
Available stable PHP versions (Thread-Safe x64):
PHP 8.3:
8.3.15
8.3.14
8.3.13
PHP 8.2:
8.2.27
8.2.26
PHP 8.1:
8.1.31
8.1.30
To install a version: phat install <version>
phat currentDisplays the currently active PHP version in XAMPP.
phat switch 8.0.30
# or use the alias
phat use 8.0.30This will:
- Stop Apache
- Backup current
php/βphp{version}/(e.g.,php7.4.33/) - Rename
php{target}/βphp/ - Update Apache config (
httpd-xampp.conf) - Start Apache
phat install 8.3.6Downloads the thread-safe x64 build from windows.php.net and extracts it to C:\xampp\php8.3.6\.
After installing, switch to it:
phat switch 8.3.6phat uninstall 8.0.30Removes an installed PHP version from your system. This will:
- Verify the version exists and is not currently active
- Ask for confirmation before deletion
- Permanently remove the PHP version directory
Note: You cannot uninstall the currently active PHP version. Switch to a different version first.
phat helpShows all available commands with examples.
| Component | Description |
|---|---|
| Directories | PHP versions are stored as C:\xampp\php{version}\. The active one is always C:\xampp\php\. |
| Apache config | httpd-xampp.conf is updated to load the correct php7apache2_4.dll or php8apache2_4.dll. |
| Module name | PHP 7.x uses php7_module, PHP 8.x uses php_module (XAMPP convention). |
| Backup | A backup of httpd-xampp.conf.bak is created on first switch. |
| Services | Apache is automatically stopped before switching and restarted after configuration updates. |
- Windows 10/11 - Required for PowerShell support
- XAMPP - Installed at
C:\xampp(default location) - PowerShell 5.1+ - Pre-installed on Windows 10/11
- .NET SDK 6.0+ - Only needed for building the MSI installer
If you want to build the installer from source:
-
Install the .NET SDK 6.0+
-
Build the MSI:
dotnet build ./installer/Phat.wixproj -c Release
-
The MSI will be created in
installer\bin\Release\
To specify a custom version:
dotnet build ./installer/Phat.wixproj -c Release -p:ProductVersion=1.0.0π For detailed troubleshooting solutions, see TROUBLESHOOTING.md
If you see "cannot be loaded. The file is not digitally signed" error:
- Open PowerShell as Administrator
- Run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - Run:
Unblock-File "C:\Program Files (x86)\Phat\phat.ps1"
β‘οΈ Full solution guide
Run your terminal as Administrator if you encounter permission errors when switching PHP versions.
β‘οΈ Full solution guide
- Check Apache error logs at
C:\xampp\apache\logs\error.log - Ensure the correct PHP DLL files exist in the PHP directory
- Verify
httpd-xampp.confhas the correct PHP module configuration
β‘οΈ Full solution guide
Apache virtual host warnings (e.g., Could not resolve host name) are unrelated to PHP switching β they come from your virtual host configuration in httpd-vhosts.conf.
Contributions are welcome! Feel free to:
- Report bugs and issues
- Suggest new features
- Submit pull requests
If you find this tool helpful, please consider:
- β Starring the repository
- π Reporting bugs
- π Improving documentation
MIT Β© pphatdev
Made with β€οΈ by pphatdev