I blog on fullstack related stuff with Laravel, Vue, Nuxt...

Written on May 20, 2022

"zsh: command not found: php" after upgrading php on MacOs Monterey

After upgrading to MacOS Monterey (MacOs 12), php was not responding in cli anymore.

php --version

# zsh: command not found: php

After I upgraded to Monterey I updated my homebrew version of php (from 8.0.5 to 8.012) but installation didn't successfully ended.

The installation created a folder flagged by homebrew with a '.reinstall' :

/usr/local/Cellar/php/8.0.12.reinstall

The php update failure was caused by my Xcode Command Line Tools being deprecated. Homebrew stated it in its installation report (but I didn't noticed it at first). What's weird is I did upgrade Xcode after upgrading to Monterey but for some reason the Xcode Command Line tools were not (as they should have).

Time to upgrade Xcode cli tools:

xcode-select --install

A prompt informed me that "The xcode-select command requires the command line developer tools. Would you like to install the tools now?" I clicked yes and installation took ages but eventually got cli tools installed.

I then re-installed php:

brew install php

And that fixed my php installation!