Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path to php executable on a mac with vscode and mamp

vscode requires path to php set for this parameter:

"php.validate.executablePath":

so I specified this:

"/Applications/MAMP/bin/php/php7.0.12/bin/php"

but it isn't recognized.

What is the correct path ?

like image 633
Robert Brax Avatar asked Nov 21 '16 18:11

Robert Brax


People also ask

Where is PHP EXE on Mac?

On a Linux or Mac OS X system, this may be available as the file /usr/bin/php. If you've installed XAMPP, you can use the program /opt/lampp/bin/php on Linux, /Applications/xampp/xamppfiles/bin/php on Mac OS X, and C:\Program Files\xampp\php\php.exe on Windows.

Where is my PHP executable path?

From below example, we can see the PHP executable file path is /usr/bin/php , and it is linked to /www/server/php/73/bin/php file ( this is the real PHP executable file ). If whereis command returns multiple PHP install path, then you can run which command to get current PHP executable file path.

How do I open PHP code in Visual Studio Mac?

1) Open visual studio code, by pressing Cmd+space type visual studio code and press enter. 2) Click on the extension button and in the search bar type PHP Debug , select the first option from Felix Becker and click on the small blue install button.

How to set PHP executable path in VSCode?

and it will show path for php executable (It will be either in /usr/bin/php or usr/local/bin/php) which you can copy from terminal. In VScode goto settings.json file and paste Sure, easy. Just follow what it's says. Go to File> Preferences > Settings ... it will open the settings.json file.

How to install Xdebug for PHP on Mac?

For macOS users, you can install the Xdebug extension for your version of PHP using Homebrew. They recommend using PECL to install it. Another option is to compile the source code and then install. PEAR/PECL is PHP's Package Repository for easy download and installation of Xdebug and also other tools.

How do I run a PHP program in Windows 7?

In Windows: 1 Go To System Properties 2 Go To Advanced Tab 3 Click "Environment Variables" 4 Select Path 5 Add a new path that points to your php 7 executable:

How to show PHP activity in VSCode?

and it will show path for php executable (It will be either in /usr/bin/php or usr/local/bin/php) which you can copy from terminal. In VScode goto settings.json file and paste Show activity on this post. Sure, easy. Just follow what it's says. Go to File> Preferences > Settings ... it will open the settings.json file.


1 Answers

I ran into this problem after installing the PHP Intellisense extension in vscode. For Intellisense to work I needed to point vscode at MAMP's version of PHP, not the default OS X version of PHP, but it did not recognise the path I was specifying.

I was able to resolve the issue by specifying the "php.executablePath" preference instead of "php.validate.executablePath".

"php.executablePath": "/Applications/MAMP/bin/php/php7.4.21/bin/php"

Here is an explanation from the author of the package:

validate has nothing to do with this extension, but is the built-in validation of VS Code. I would disable that, because you will get duplicate validation. php.executablePath should be set to the path of the binary

like image 187
Jonathan Nicol Avatar answered Sep 28 '22 06:09

Jonathan Nicol