Skip to content

Latest commit

 

History

History
312 lines (207 loc) · 8.77 KB

File metadata and controls

312 lines (207 loc) · 8.77 KB

[pxp] - Personal Xampp PHP version switcher for CLI

[pxp] Personal Xampp PHP version switcher for CLI. A simple yet powerful CLI tool to manage multiple PHP versions in XAMPP on Windows.

Release

Features

  • 🔄 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

Setup

Option 1: Install from MSI (Recommended)

Download the latest MSI installer from Releases and run it. The installer will automatically add pxp to your PATH.

Option 2: Manual Installation

  1. Clone or download from GitHub:
git clone https://github.com/pphatdev/php-version-switcher.git
  1. 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.

  1. Open a new terminal and run:
pxp help

Note: Pxp is designed for Windows Command Prompt or PowerShell. If using Git Bash or other bash terminals, see the Git Bash compatibility guide.

Commands

Show version

pxp -v
# or
pxp --version

Displays the current Pxp version.

List installed versions

pxp list
# or explicitly list local versions
pxp list -php -local

Output example:

Installed PHP versions:
* 7.4.33 (active, php7)
  8.0.30 (8.0.30)
  8.2.27 (8.2.27)

List available PHP versions globally

pxp list -php -global

This 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: pxp install <version>

Show current version

pxp current

Displays the currently active PHP version in XAMPP.

Switch PHP version

pxp switch 8.0.30
# or use the alias
pxp use 8.0.30

This will:

  1. Stop Apache
  2. Backup current php/php{version}/ (e.g., php7.4.33/)
  3. Rename php{target}/php/
  4. Update Apache config (httpd-xampp.conf)
  5. Start Apache

Download & install a new PHP version

pxp install 8.3.6

Downloads the thread-safe x64 build from windows.php.net and extracts it to C:\xampp\php8.3.6\.

After installing, switch to it:

pxp switch 8.3.6

Uninstall a PHP version

pxp uninstall 8.0.30

Removes an installed PHP version from your system. This will:

  1. Verify the version exists and is not currently active
  2. Ask for confirmation before deletion
  3. Permanently remove the PHP version directory

Note: You cannot uninstall the currently active PHP version. Switch to a different version first.

Help

pxp help

Shows all available commands with examples.

How It Works

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.

Requirements

  • 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

Building the MSI Installer

If you want to build the installer from source:

  1. Install the .NET SDK 6.0+

  2. Build the MSI:

    dotnet build ./installer/Pxp.wixproj -c Release
  3. The MSI will be created in installer\bin\Release\

To specify a custom version:

dotnet build ./installer/Pxp.wixproj -c Release -p:ProductVersion=1.0.0

Troubleshooting

📖 For detailed troubleshooting solutions, see TROUBLESHOOTING.md

PowerShell Execution Policy Error

If you see "cannot be loaded. The file is not digitally signed" error:

  1. Open PowerShell as Administrator
  2. Run: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  3. Run: Unblock-File "C:\Program Files (x86)\Pxp\pxp.ps1"

➡️ Full solution guide

Permission Errors

Run your terminal as Administrator if you encounter permission errors when switching PHP versions.

➡️ Full solution guide

Apache Won't Start

  1. Check Apache error logs at C:\xampp\apache\logs\error.log
  2. Ensure the correct PHP DLL files exist in the PHP directory
  3. Verify httpd-xampp.conf has the correct PHP module configuration

➡️ Full solution guide

VHost Warnings

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.

Documentation

For Users

For Contributors

Troubleshooting Guides

Contributing

Contributions are welcome! We appreciate any help in improving pxp-cli.

How to Contribute

  1. 🐛 Report bugs - Open an issue
  2. 💡 Suggest features - Request a feature
  3. 🔀 Submit pull requests - Read the contributing guide
  4. 📝 Improve documentation - Help make docs better
  5. Star the repository - Show your support

Before contributing, please read:

Development Setup

# Clone the repository
git clone https://github.com/pphatdev/pxp-cli.git
cd pxp-cli

# Test the script
.\pxp.ps1 help

# Build the installer
dotnet build ./installer/Pxp.wixproj -c Release

Support

Getting Help

Show Your Support

If you find this tool helpful, please consider:

  • Star the repository on GitHub
  • 🐛 Report bugs you encounter
  • 💡 Suggest features you'd like to see
  • 📝 Improve documentation with corrections and additions
  • 🤝 Share with others who might benefit

License

MIT © pphatdev


Made with 😧 to resolve PHP version switching issues | pphatdev