Home  >  Article  >  Backend Development  >  How to Manage Multiple PHP Versions on Mac with Homebrew?

How to Manage Multiple PHP Versions on Mac with Homebrew?

Barbara Streisand
Barbara StreisandOriginal
2024-10-20 10:46:02284browse

How to Manage Multiple PHP Versions on Mac with Homebrew?

Managing PHP Versions on Mac OSX with Homebrew

Developers often need to switch between different PHP versions while working on projects. This is especially true for testing applications across multiple PHP versions. Homebrew, a package manager for Mac, provides a convenient way to install and manage multiple PHP versions on your system.

To install multiple PHP versions using Homebrew, run the following commands:

# Install PHP 5.3
brew install php@5.3

# Install PHP 8.2
brew install php@8.2

Once installed, you can switch between the PHP versions using the brew link and brew unlink commands. Here's an example of switching between PHP 7.4 and PHP 7.3:

# Unlink PHP 7.4
brew unlink php@7.4

# Link PHP 7.3
brew link php@7.3

Note: Both versions of PHP must be installed for these commands to work. After switching versions, verify that the desired version is active by running the php -v command, which will display the current PHP version.

The above is the detailed content of How to Manage Multiple PHP Versions on Mac with Homebrew?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn