Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to point to PHP executable? #37

Closed
chrmarti opened this issue Dec 2, 2016 · 15 comments
Closed

How to point to PHP executable? #37

chrmarti opened this issue Dec 2, 2016 · 15 comments

Comments

@chrmarti
Copy link

chrmarti commented Dec 2, 2016

From @TRE8 on December 1, 2016 5:42

  • VSCode Version: 1.7.2
  • OS Version: Max osX 10.11

Steps to Reproduce:

Hi, I'm trying to point VSCode to my PHP executable. I'm on a Mac and using MAMP Pro, which I believe is the PHP executable that I'm suppose to point to.

I've gone into settings.json and added this line:

// Points to the php executable.
"php.validate.executablePath":  "/Applications/MAMP/bin/php/php7.0.12/bin"

Here's an image to help if needed.
screen shot - 2016-11-30 at 9 37 46 pm

Not sure if I entered the file path wrong or if I should use a different one, it doesn't seem to click. I still get a message that PHP executable is not connected to VSCode.

Also, new to Github and trying to tag this as a question but don't see an option to tag a label to this post.

Copied from original issue: microsoft/vscode#16309

@chrmarti
Copy link
Author

chrmarti commented Dec 2, 2016

The path needs to point at the php executable. (See https://code.visualstudio.com/Docs/languages/php.)

@chrmarti
Copy link
Author

chrmarti commented Dec 2, 2016

From @TRE8 on December 1, 2016 17:43

Thanks, I see in the docs it says
{ "php.validate.executablePath": "c:/php/php.exe" }

But I'm on a Mac :/

Can't seem to figure out where the PHP executable is located.

@chrmarti
Copy link
Author

chrmarti commented Dec 2, 2016

Have you tried "php.validate.executablePath": "/Applications/MAMP/bin/php/php7.0.12/bin/php"?

@chrmarti
Copy link
Author

chrmarti commented Dec 2, 2016

From @TRE8 on December 1, 2016 23:43

Good idea and I tried your suggestion but still get the message

The language server needs at least PHP 7 installed. Version found: 5.5.30

I tried adding ~ before "/Application" and got the following message:
"php.validate.executablePath": "~/Applications/MAMP/bin/php/php7.0.12/bin/php"

Cannot validate the php file. The php program was not found. Use the 'php.validate.executablePath' setting to configure the location of 'php'

@klaasvw
Copy link

klaasvw commented Jan 2, 2017

Have you tried php.executablePath instead of php.validate.executablePath? Even though the settings editor warns it doesn't recognise the configuration setting it does seem to solve the problem.

@felixfbecker
Copy link
Owner

felixfbecker commented Jan 2, 2017

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, eg "/Applications/MAMP/bin/php/php7.0.12/bin/php".
And it needs to be at least PHP 7.

@AmirSimantov
Copy link

@klaasvw - your suggestion of using php.executablePath instead of php.validate.executablePath works in my case. Thanks!

@ramseyjiang
Copy link

"php.executablePath":'/usr/local/bin/php',

I did it as above, but block still not work

@erkanarslan
Copy link

I think this plugin does not detect php on linux environment or cannot use it. Because I set

"php.executablePath": "/usr/bin/php"

and it still does not work.

@vladonof
Copy link

vladonof commented Jul 18, 2019

Same issue here caused by having docker persistent storage in the root of the project.
What I ended up doing was chowning the persistent database folder, opening vs code, confirm it works, and only after that I would spin up my containers. It's annoying, but it works.

Also, this is what I've got in my settings

    "php.executablePath": "/usr/bin/php",
    "php.validate.enable": true,
    "php.validate.run": "onSave",
    "php.suggest.basic": false,

@Vangoly
Copy link

Vangoly commented Aug 15, 2019

Mac user.

Good evening guys. I am struggling to have xdebug working and I would appreciate some help.
Following this guide I think it is correct to add
"php.executablePath": "/Applications/MAMP/bin/php/php7.3.7/bin/php"
to the settings.json file to override the default values that are described here.
However, when I do try to edit the settings.json file I get a yellow outline saying that something is wrong. If I go to Code > preferences > settings I do not get the whole set of values, instead I get an User Interface that allows me to navigate through both User and Workspace settings. As a consequence, I am not able to find php.executablePath and then edit it.

Furthermore, I would like to disable php.validate.enable: true as @felixfbecker kindly suggested, but as per the same problem, I cannot find it as well.

All this pain, as I said, in order to have 'listen xdebug' working correctly. So far, it works only if I do restart constantly my MAMP servers.

Thank you so much for your help.

D.

I attach two files
Schermata 2019-08-15 alle 21 26 04

Schermata 2019-08-15 alle 21 33 29

@razan-rai
Copy link

razan-rai commented Jun 17, 2020

Within the Terminal, run vim ~/.bash_profile

Typeiand then paste the following at the top of the file:

export PATH=/Applications/MAMP/bin/php/php7.3.8/bin:$PATH
Hit ESC, Type :wq, and hit Enter

In Terminal, run source ~/.bash_profile

@theMyth721
Copy link

theMyth721 commented Aug 23, 2021

I have just updated to macOS Big Sur 11.5.2 and also installed PHPIntellisense. I am not sure what is broken but VSCode seems to be pointing to the wrong PHP.
Its pointing to /usr/bin/php instead of /opt/homebrew/bin/php

I tried editing settings.json changed both php.executablePath and validate.executablePath and none made any difference

I have asked a question here on stack overflow:

https://stackoverflow.com/questions/68899144/wrong-php-version-executable-in-vscode-terminal-but-works-perfectly-in-mac-termi

@Dominhodelapaz
Copy link

I thaught I was close but no, Razan, the last was good until /Users/.../.bash_profile:1: permission denied: /Users/.../.profile
...@192 projekt %

@vzip
Copy link

vzip commented Apr 1, 2022

Within the Terminal, run vim ~/.bash_profile

Typeiand then paste the following at the top of the file:

export PATH=/Applications/MAMP/bin/php/php7.3.8/bin:$PATH Hit ESC, Type :wq, and hit Enter

In Terminal, run source ~/.bash_profile

THX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests