"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Switch Between PHP Versions Effortlessly on macOS?

How to Switch Between PHP Versions Effortlessly on macOS?

Published on 2024-11-09
Browse:851

How to Switch Between PHP Versions Effortlessly on macOS?

Effortless Switching Between PHP Versions on macOS

To seamlessly test your application across various PHP versions (e.g., 5.3 to 8.2), you'll need to install the different versions and establish a mechanism for effortlessly switching between them.

Installing PHP Versions:

Utilize Homebrew, a package manager specifically designed for macOS:

brew install php53
brew install php54
...
brew install php82

Switching PHP Versions:

Once you have multiple PHP versions installed, employ Homebrew's link and unlink commands to toggle between them:

# Switch to PHP 7.4
brew unlink php73
brew link php74

This command unlinks PHP 7.3 from the system and links PHP 7.4 instead.

Verifying Version:

To confirm the active PHP version, execute the following command in the Terminal:

which php

This will display the path to the active PHP binary, indicating the version you have successfully switched to.

Note:

For the aforementioned commands to function, ensure you have installed all required PHP versions using Homebrew.

Release Statement This article is reprinted at: 1729388236 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3