MacOS Monterey no only seems to support PHP within Automator.
You can run PHP from the Terminal without error (if installed via Brew) but running PHP scripts from Automator in a "Run Shell Script" gives the error
php: command not found
In the Terminal, running
which php
Results in /usr/local/bin/php.
Interestingly the newer Shortcuts app supports PHP scripts. Any ideas how to get Automator working with PHP again?