xxxxxxxxxx
Add the PHP formulae
brew tap shivammathur/php
Choose the PHP version – this example uses 7.4
brew install shivammathur/php/php@7.4
Link the PHP Version
brew link --overwrite --force php@7.4
Restart the Terminal
php -v
xxxxxxxxxx
Add the PHP formulae
brew tap php
Choose the PHP version – this example uses 7.4
brew install php@7.4
Link the PHP Version
brew link --overwrite --force php@7.4
Restart the Terminal
php -v
xxxxxxxxxx
#install php
brew install php
# or install specific version
brew install php@8.2
xxxxxxxxxx
# Step 1: Check if PHP is installed
php -v
# If PHP is not installed, install it with the preferred package manager
# For example, using Homebrew on macOS:
brew install php
# Step 2: Add PHP to the system's PATH
# Open the .zshrc file in a text editor
nano ~/.zshrc
# Add the following line to the end of the file
export PATH="/usr/local/bin:$PATH"
# Save the file and exit the text editor
# Step 3: Refresh the terminal configuration
source ~/.zshrc
# Verify if PHP is now accessible
php -v