Visual Studio Code, sebagai text editor yang mendukung berbagai macam bahasa pemrograman, juga memberikan dukungan terhadap php. Agar penggunaan php pada VSCode optimal, executable dari php sebaiknya dicantumkan pada settings. Berikut adalah caranya:
Pesan ini muncul karena VS Code berusaha untuk melakukan validasi code dengan PHP, tapi tidak dapat menemukan instalasi PHP pada system.
Untuk mengatasi masalah ini cukup sederhana, yaitu tinggal klik tombol Open Setting pada dialog yang mucul lalu edit settings.json, dan akan terbuka tab seperti gambar berikut:
php.validate.executablePath kita isi dengan path dimana lokasi php.exe berada. Sebagai contoh, apabila kita menggunakan XAMPP maka php.exe secara default berada di C:\xampp\php. Kemudian tambahkan php.exe menjadi C:\xampp\php\php.exe.
Apabila muncul warning seperti gambar di atas, maka ganti backslash menjadi double backslashes, sehingga menjadi C:\\xampp\\php\\php.exe.
Setelah selesai edit, jangan lupa save.
Settings file locations
Berikut ini adalah lokasi tempat settings file berada:
- Windows
%APPDATA%\Code\User\settings.json - macOS
$HOME/Library/Application Support/Code/User/settings.json - Linux
$HOME/.config/Code/User/settings.json
Settings untuk workspace dapat ditemukan di dalam folder .vscode pada root folder workspace.
Cara lain untuk membuka settings.json adalah melalui Command Palette dengan shortcut Ctrl+Shift+P atau melalui menu View > Command Palette, lalu ketik settings.json
Did you find this message when creating a PHP file in VSCode?
Cannot validate since no PHP executable is set. Use the setting 'php.validate.executablePath' to configure the PHP executable.
1. First of all
Open settings.json and paste this line "php.validate.executablePath": "your_unit:/xampp/php/php.exe"
, paste this in the last line of your settings.json.
Ok, the annoying message does not pop up anymore, and now?.
That's all
not kidding really😄 but... we want to debug PHP also in VSCode right?.
2. CRTL+SHIFT+P
type ext install PHP Debug
and install the first match.
Run XAMPP server, create a php file like test.php with phpinfo[]; open it in your browser localhost/test.php
copy the HTML source [what you see] and paste it into here: xdebug.org/wizard now hit analise my phpinfo[] output.
Follow the instruction and download
the .dll file, install it in the folder your_unit:\xampp\php\ext .
3. Almost done!
Now open you php.ini from XAMPP and paste the code in the very last line
[XDebug] xdebug.remote_enable = 1 xdebug.remote_autostart = 1 zend_extension = "you_unit:\xampp\php\ext\downloadedfile.dss
Save it!
Now, restart XAMPP and VSCode and you should be done!
Last thing
Wondering how it works?
Open your project on your browser, set a stop point in VSCode and see the magic!
You can follow the documentation at xdebug.org and also at VSCode extension page.
Thanks for read, it's my really first post
I have a development environment based in docker.
Everytime that I open VSCode I get this message:
Cannot validate since no PHP executable is set. Use the setting 'php.validate.executablePath' to configure the PHP executable.
Somebody know how to set php.validate.executablePath in this case?
I have no idea how to do it.
asked May 3, 2017 at 19:38
Nicolas TakashiNicolas Takashi
1,2901 gold badge9 silver badges11 bronze badges
6
Here is a screenshot.
- Don't forget to escape
\
- You don't have to add it to the Path
Cave Johnson
6,2405 gold badges37 silver badges53 bronze badges
answered Sep 18, 2017 at 7:57
Mohamed ElrashidMohamed Elrashid
7,4356 gold badges27 silver badges45 bronze badges
7
For linux users: if you don't have PHP installed then first download,
then in terminal type
$ whereis php
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
php.validate.executablePath: /usr/bin/php
answered Sep 25, 2018 at 0:53
2
In my case using XAMPP is like this
"php.validate.executablePath": "C:/xampp/php/php.exe"
hope that answer your question
answered Jul 20, 2020 at 6:20
SETIA1SETIA1
2412 silver badges2 bronze badges
3
Sure, easy. Just follow what it's says.
Go to File> Preferences > Settings ... it will open the settings.json file.
add the following code:
{"php.validate.executablePath": "Here you put your PHP.exe path"}
You have to know where te PHP.exe file is in your computer, search in the php>bin folder.
Hope it works for you
answered May 18, 2017 at 16:38
JulianJulian
1452 bronze badges
2
I had the same problem but found the fix here.
In Windows:
- Go To System Properties
- Go To Advanced Tab
- Click "Environment Variables"
- Select Path
- Add a new path that points to your php 7 executable:
answered Sep 17, 2017 at 16:24
rayray
8,3977 gold badges43 silver badges57 bronze badges
My case, I'm using Laragon, so you should search where is your php.exe.
By VSCode just add.
"php.executablePath": "C:\\laragon\\bin\\php\\php-7.2.19-Win32-VC15-x64\\php.exe"
on settings.json.
Dharman♦
27.9k21 gold badges75 silver badges127 bronze badges
answered Mar 27, 2020 at 12:20
1
VSCode Linux Users:
Step 1: In your terminal type
whereis php
In my case "php: /opt/lampp/bin/php"
Step 2:
{
"php.validate.executablePath": "/opt/lampp/bin/php"
}
answered Feb 3, 2021 at 10:20
0
"php.validate.executablePath": "C:/php/php.exe"
wont work due to incorect escaping
try this;
"php.validate.executablePath": "C:\\php\\php.exe"
answered Sep 29, 2019 at 12:11
I have ubuntu and XAMPP. The following worked for me.
Press CTRL + P Type settings.json and hit ENTER.
Add the following line in settings.json
{
...
"php.validate.executablePath": "/opt/lampp/bin/php",
...
}
Make sure to proper syntax.
answered Aug 27, 2021 at 5:48
Unix / Linux / Mac / WSL ,
Step 1 : Find PHP path
whereis php
Response will show you where your php directories are.
user@User:~$ whereis php
php: /usr/bin/php /usr/bin/php8.0 /usr/bin/php8.1 /usr/lib/php /etc/php /usr/share/php8.0-opcache
/usr/share/php8.0-xml /usr/share/php8.1-curl /usr/share/php8.1-opcache /usr/share/php8.0-gd
/usr/share/php7.0-gd /usr/share/php7.0-common /usr/share/php8.0-readline /usr/share/php8.0-mysql
/usr/share/php8.0-zip /usr/share/php8.1-mbstring /usr/share/php8.1-xml /usr/share/php8.0-mbstring
/usr/share/php8.0-common /usr/share/php8.0-curl /usr/share/php8.1-readline /usr/share/php8.1-common
/usr/share/man/man1/php.1.gz
Step 2 : Configure VS-Code
Go to -> "Preference -> Settings"
Search for -> "php path"
Then click -> "Edit in settings.json"
In my case I had multiple.
So I chose the
one I wanted from the available versions and my VS-Code looked like this
"php.validate.executablePath": "/usr/bin/php8.1",
answered May 13 at 9:13
13garth13garth
4601 gold badge10 silver badges20 bronze badges
Download PHP, in my case, I downloaded from here: //windows.php.net/download/
Copy and paste the files to a location on your computer, and set the path:
"php.validate.executablePath": "C:/php/php.exe"
answered Jul 21, 2017 at 14:17
NuuuNuuu
1,5702 gold badges10 silver badges12 bronze badges
1
If you get this on windows in VS code click on the blue 'open settings' button. Near the bottom of the screen this opens there's a link to enter the settings, click this to open the settings.json file. Edit the file to look like this:
{
"php.executablePath" : "C:/php-7.4.2-nts-Win32-vc15-x64/php.exe",
"php.validate.executablePath" : "C:/php-7.4.2-nts-Win32-vc15-x64/php.exe"
}
where C:/php-7.4.2-nts-Win32-vc15-x64 is the path to your PHP dir
answered Feb 18, 2020 at 15:19
R MacR Mac
134 bronze badges
I don't know if this helps but I ran into the same problem with the extension PHP Intelephense in Visual Studio Code. What I did is read the instructions so the extension could work properly. So I disabled PHP Language Features by searching "@builtin PHP" in the extensions. Also, other [3rd party] PHP extensions that provide similar functionality should also be disabled for best results. Finally, I added glob patterns for non-standard PHP file extensions to the files.associations setting. For example: "files.associations": { "*.module": "PHP" }
Doing this made the error go away. I'm new to PHP too, let me know if this is the correct way of solving this problem with PHP Intelephense.
answered Jan 15, 2021 at 16:52
If you're using VScode and have installed Php through MAMP, the default path should be:
C:/MAMP/bin/php/php7.4.1/php.exe
/
not \
Suraj Rao
29.1k11 gold badges95 silver badges100 bronze badges
answered Feb 12, 2021 at 14:21
I simply used double forward slashes and it worked, like so:
"php.validate.executablePath": "C:\\xampp\\php\\php.exe",
linktoahref
7,3263 gold badges29 silver badges48 bronze badges
answered May 2, 2020 at 5:56
I also had this error. I have installed Laragon and this addition in setting.json worked for me.
"php.executablePath":"C:/laragon/bin/php/php-7.2.19-Win32-VC15-x64/php.exe"
answered Mar 24 at 15:59
"php.validate.executablePath": "C:\xamp\php\php.exe" this is working for this case
answered Jul 23 at 14:16
1
IF using Laragon...Dont forget to change \ to /
"php.executablePath": "C:/laragon/bin/php/php-7.4.5-Win32-vc15-x64/php.exe",
answered Dec 12, 2020 at 3:11
samjcosamjco
3475 silver badges13 bronze badges
- Go to 'Preference' -> 'Settings'
- Search for>
php path
- Then click
Edit in settings.json
- Then just put your directory with [DOUBLE Backslash].
Here is an example of mine:
C:\\php\\php.exe
Here is the format:
drive:\\folder_name\\php.exe
This should fix the problem.
answered Sep 7, 2021 at 2:14
php.validate.executablePath in laragon
In my case using laragon is like this
"php.validate.executablePath": "C:\\laragon\\bin\\php\\php-7.4.19-Win32-vc15-x64\\php.exe"
- php-7.4.19-Win32-vc15-x64 : Note that this part of your file name may be different
answered Feb 19 at 9:15
For Wampserver:
Inside settings.json
"php.validate.executablePath": "C:/wamp64/bin/php/php7.4.26/php.exe"
answered Sep 1 at 11:02
If php is inside a docker container and you don't need it or don't want to install it on you local system, you can create a php wrapper script like it is suggested here: //github.com/felixfbecker/vscode-php-intellisense/issues/471
I prefer to use the remote container Microsoft extension on vscode and work inside the container itself.
answered Sep 7 at 17:30
I also got this error message.
The path to php.exe
was already set in my System Environment Variables.
The error went away when I commented out "php.validate.executablePath": "c:/path/to/php7.2.10/php.exe"
, in the settings.json
file in VSCode.
Nik
2,5852 gold badges22 silver badges24 bronze badges
answered Jul 1, 2019 at 19:43