1

MacOS Monterey does not come with PHP. I know I could install it. But I also use MAMP, which includes its own version/s of PHP.

Visual Studio Code needs to know the location of PHP, for example, for serving projects into the web browser.

MAMP comes with several versions of PHP, eg. /Applications/MAMP/bin/php/php7.4.21/bin/php

In VS Code settings (~/Library/Application Support/Code/User/settings.json), I'm aware of two relevant settings:

  • phpserver.ip (starts blank)
  • php.validate.executablePath (starts missing, guided to add: "Cannot validate since a PHP installation could not be found. Use the setting 'php.validate.executablePath' to configure the PHP executable.")

But, when I add /Applications/MAMP/bin/php/php7.4.21/bin/php to either of them, it doesn't seem to go right, even with the MAMP server started.

When trying to serve the page in PHP Server, the notice "PHP not found" appears.

Robert Andrews
  • 1,209
  • 4
  • 23
  • 47

1 Answers1

0

Various answers show how to add the MAMP php path to your VS Code settings.

But I was still getting zsh: command not found: php

However, the answer may lay outside of VS Code.

On macOS, the default shell has apparently changed from Bash to Zsh, so it's possible that you are using the Zsh shell instead of Bash.

I modified the Zsh profile to add the MAMP path to that...

nano ~/.zshrc to edit

Add your path for your chosen version , eg. /Applications/MAMP/bin/php/php7.4.33/bin

That instantly caused running to php to work.

Robert Andrews
  • 1,209
  • 4
  • 23
  • 47