Install/Upgrade PHP in MacOS

1) Update & Upgrade brew

brew update && brew upgrade

2) To install, run this command.

brew install php@a.b
# E.g.
brew install php@8.3

3) To upgrade, run this command.

brew upgrade php@a.b
# E.g.
brew upgrade php@8.3

4) Check your upgrade

which php
php -v

5) Restart the service if needed

brew services restart php

If you are using the PHP in IDE such as PHPStorm, remember to update the Path.

(Before)

(After)


AI Summary
gpt-4o-2024-05-13 2024-09-07 12:09:01
This blog post provides a step-by-step guide to installing or upgrading PHP on macOS using Homebrew. It includes commands for updating Homebrew, installing or upgrading PHP, verifying the installation, and restarting the PHP service if needed. Additionally, it advises updating the PHP path in IDEs like PHPStorm.
Chrome On-device AI 2024-12-21 22:12:21

Share Article