The swtp
script allows you to easily switch between different PHP versions installed on your system. It additionally has the capability to install any missing PHP versions using Homebrew.
- Homebrew must be installed on your macOS system. How to do this see Homebrew
- Your system should have the Bash shell installed, although the installation script supports various other shells bash, zsh, fish, csh, ksh, and dash.
To install swtp in a manner similar to Homebrew, you can use the following one-liner. This will download and execute the install.sh
script, placing the swtp tool into $HOME/.swtp/bin/swtp
.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/kisztof/swtp/latest/install.sh)"
The bootstrap script now includes a Homebrew installation check. When you run the script, it will automatically prompt you to install Homebrew if it's not already installed.
Once you've executed install.sh
, you can switch PHP versions easily using swtp
.
swtp 7.4 # Switches to PHP 7.4
swtp 8.0 # Switches to PHP 8.0
If the desired PHP version is not installed, swtp
will automatically attempt to install it using Homebrew.
To update swtp to the latest version, run:
swtp --update
This will fetch the latest version from the GitHub repository and update the script.
To display the current version of swtp, run:
swtp --version
This will show the version of swtp that you are currently using.
The install.sh
script supports the following shells:
- Bash
- Zsh
- Fish
- Csh
- Ksh
- Dash