Page 1 of 1

How to set up VS Code to use MAMP's own PHP?

Posted: Sat Mar 05, 2022 11:30 am
by robertandrews
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.