In terminal I ran a regular command - compose update. Something I've completed thousands of times previously. However, this time I received the following response:
env: php: No such file or directory
What gives?
Well, thinking through what had recently changed... The only major change was upgrading OSX to Monterey. So a little of Googling and found yep this could be the cause. PHP has been removed from MacOS since v12 (Monterey), so you first need to install it on your own to use it. For a OSX user, the easiest way to do this is using Homebrew.
brew install php@7.4 brew-php-switcher
Note, obviously I'm installing PHP 7.4, however you can change this to 8.0 or 8.1 depending on your requirements.
Once PHP has been installed, you will need to restart through
brew services restart php@7.4
To which you will see the following output
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Enumerating objects: 1708, done.
remote: Counting objects: 100% (587/587), done.
remote: Compressing objects: 100% (345/345), done.
remote: Total 1708 (delta 259), reused 542 (delta 228), pack-reused 1121
Receiving objects: 100% (1708/1708), 492.28 KiB | 4.83 MiB/s, done.
Resolving deltas: 100% (735/735), done.
Tapped 1 command (44 files, 629.8KB).
==> Successfully started `php@7.4` (label: homebrew.mxcl.php@7.4)
PHP is installed, but is it running?
Checking if php is running
How to check if PHP is running? Execute the command:
which php
However, the response was
php not found
Hmmm, seems I need to link PHP so it can be found. Which is achieved by:
brew link php@7.4
And you'll see the the following in Terminal
Linking /usr/local/Cellar/php@7.4/7.4.27... 25 symlinks created.
If you need to have this software first in your PATH instead consider running:
echo 'export PATH="/usr/local/opt/php@7.4/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.4/sbin:$PATH"' >> ~/.zshrc
Now if you run which php, the output is looking much better
which php
/usr/local/bin/php
Back to my original command
composer update
The response...
Loading composer repositories with package information
Updating dependencies
And on it goes. Back in action!