/swtp

A versatile CLI tool for effortlessly switching between different PHP versions on macOS.

Primary LanguageShell

swtp - Switch PHP Version

GitHub tag (latest by date)

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.

Articles

Prerequisites

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

One-Step Automated Installation

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.

Usage

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.

Auto-Update

To update swtp to the latest version, run:

swtp --update

This will fetch the latest version from the GitHub repository and update the script.

Display Current Version

To display the current version of swtp, run:

swtp --version

This will show the version of swtp that you are currently using.

Supported Shells

The install.sh script supports the following shells:

  • Bash
  • Zsh
  • Fish
  • Csh
  • Ksh
  • Dash