Use brew to manage your PHP version on MacOS
Introduction
In this article, I will try to demonstrate how to easily manage PHP versions using Brew in a macOS system.
Background
I noticed that many people are unaware of how to manage PHP versions on their local machines. You don’t have to use docker for PHP version management.
Install
You can install PHP versions in two ways: without specifying a version (it will install the latest version), or by specifying a version, in which case it will install the specific PHP version you request.
brew install php
brew install php@8.0
Unlink and Link
You can easily link and unlink PHP versions using brew link
and brew unlink
. These commands allow you to switch between different PHP versions on your macOS system, making it convenient for managing different projects with specific PHP requirements.
Aware
Keep in mind that each PHP version must be installed separately, and any extensions and configurations you install for one version won’t be available for another. It’s essential to configure each PHP version and its associated extensions as needed for your specific projects.