Just add below code in setting.json in VS Code

"phpfmt.php_bin": "C:/xampp/php/php.exe"

in my case the location is in xampp so just add your php.exe location.

Answer from Yash Sahane on Stack Overflow
🌐
GitHub
github.com › kokororin › vscode-phpfmt › issues › 19
phpfmt: cannot find php bin · Issue #19 · kokororin/vscode-phpfmt
March 18, 2018 - Hi, I don't have PHP directory on my PATH when I start code. I Add this setting to my user settings: "phpfmt.php_bin": "C:/Program Files/php/7_2-nts/php.exe", yet your plugin keeps complaing phpfmt: cannot find php bin. Why is that? Does...
Author   bardware
🌐
CouponXoo
couponxoo.com › phpfmt-php_bin-php-is-invalid-visual-studio-code
Phpfmt Php_bin Php Is Invalid Visual Studio Code - 05/2021
Sep 12, 2017 PHP should be in your PATH already, so just "phpfmt.php_bin": "php" will do. ... phpfmt: php_bin "c:/php/php-7.2.5-Win32-VC15-x64/php.exe" is invalid ...
🌐
GitHub
github.com › kokororin › vscode-phpfmt › issues › 1
how to set php.exe path · Issue #1 · kokororin/vscode-phpfmt
March 10, 2017 - kokororin / vscode-phpfmt Public · Notifications · You must be signed in to change notification settings · Fork 29 · Star 135 · New issueCopy link · New issueCopy link · Closed · Closed · how to set php.exe path#1 · Copy link · ooing · opened · on Sep 13, 2017 ·
Author   ooing
🌐
Eclipse
genuitec.com › home › topics › codemix & angular ide › getting help › phpfmt: run phpfmt failed
phpfmt: run phpfmt failed - Genuitec
February 8, 2019 - Can you please try adding this setting to the settings.json and see it if helps fix the problem with formatting? : "phpfmt.php_bin": "D:/xampp/php/php.exe" // it should point to the PHP executable.
🌐
GitHub
github.com › kokororin › vscode-phpfmt
GitHub - kokororin/vscode-phpfmt: Integrates phpfmt into VS Code
A: Since phpfmt has no maintainers, only Serious bugs will be fixed. A: We now use fmt.stub.php from driade's phpfmt8 which is very updated.
Starred by 144 users
Forked by 29 users
Languages   TypeScript 98.5% | TypeScript 98.5%
🌐
GitHub
github.com › nanch › phpfmt_stable › issues › 4
Why doesn't it work? · Issue #4 · nanch/phpfmt_stable
May 14, 2016 - My phpfmt.sublime-settings file is { "version": 4, "php_bin":"D:\xampp\php", // "format_on_save":true, "option": "value" } I've also tried "php_bin":"D:\xampp\php", but ST complains about invalid escapes. I've also tried "php_bin":"D:/xampp/php", which is not windows syntax, but anyway, that doesn't work.
Author   ThinkALot
Find elsewhere
🌐
Package Control
packagecontrol.io › packages › phpfmt
phpfmt - Packages - Package Control
Edit the configuration file at %AppData%\Sublime Text\Packages\phpfmt\phpfmt.sublime-settings and set the php_bin path:
🌐
Eclipse
genuitec.com › home › topics › codemix & angular ide › getting help › cannot set php.executablepath & phpfmt.php_bin
Cannot set php.executablePath & phpfmt.php_bin - Genuitec
June 18, 2018 - That error message is cryptic and we’ll look into improving it 🙂 Can you try and set these values at the User / Workspace level instead? ... Setting it with following “C:/php/php.exe” under Window –> Preferences –> CodeMix –> User Settings worked!
🌐
npm
npmjs.com › package › vscode-phpfmt
vscode-phpfmt - npm
A: Since phpfmt has no maintainers, only Serious bugs will be fixed. A: We now use fmt.stub.php from driade's phpfmt8 which is very updated.
      » npm install vscode-phpfmt
    
Published   Feb 15, 2025
Version   1.2.41
Author   kokororin
🌐
DevPress
devpress.csdn.net › cloud › 63259cf2fd0b112779161d24.html
phpfmt php formatting extension eror: phpfmt: php_bin "php" is invalid_phpstorm_开发云应用-开发云
Answer a question Recently I updated my VS code on my macOS. I'm now running vs code version 1.41.1. Ever since the reinstall, the phpfmt extension is no longer working and giving me the phpfmt: php_b 开发云应用 开发云
🌐
Stack Overflow
chat.stackoverflow.com › transcript › 126814
New Answers to Old Questions Headquarters - 2021-08-14 (page 1 of 2)
[ Natty ] php phpfmt php formatting extension eror: phpfmt: php_bin "php" is invalid By: Yash Sahane 2.5;
🌐
YouTube
youtube.com › watch
vscode power tips - phpfmt tips and tricks for your php code - YouTube
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
Published   March 25, 2020
🌐
Cnasolution
cnasolution.com › questions › 34160 › phpfmt-php-formatting-extension-eror-phpfmt-php-bin-ldquo-php-rdquo-is-invalid
phpfmt php formatting extension eror: phpfmt: php_bin “php” is invalid | cna solution
on my macOS. I'm now running vs code version 1.41.1. Ever since the reinstall, the phpfmt extension is no longer working and giving me the phpfmt: php_bin
🌐
GitHub
github.com › nanch › phpfmt_stable › issues › 39
phpfmt Does Not Recognize PHP Binary Even Though Folder Loc Is Correct · Issue #39 · nanch/phpfmt_stable
I downloaded the PHP7.2 files, updated the environment variables path, tested in the console and everything seems fine and dandy. Correct version and all. However, when I specify the php executable file path in the phpfmt settings, then edit code, phpfmt gives an error saying that it cannot find the PHP binary file for some very strange reason.
Top answer
1 of 16
85

First, go to File->Preferences->User settings, A window will come like below image.

Now change the setting.json file like below image and save:

If PHP is not installed in your system, download php from here: windows.php.net/download, unzip to C: drive, set "php.validate.executablePath": "C://path.to.your.php.folder//php.exe"

If php is installed in your system simply set the path of your php.exe file like below:

"php.validate.executablePath": "C://path.to.your.php.folder//php.exe"

hint: In my case I use XAMPP which is installed in the D: drive, so my setting is below

"php.validate.executablePath": "D://xampp//php//php.exe"

Mind the double forward slashes.

2 of 16
19

How you can fix this:

If you have installed xampp for making a localhost database this is for if your new to php and are getting the error in the picture and this is how to fix it. I am using visual studio code.

How to get rid of error:

1) Get to settings:

Method 1:

  • Click the button that says settings on the error (bottom right corner of the error)

Method 2:

  • Click the shortcut for settings (ctrl + ,) ( if doesn't work resort to method 3 or 4 )

Method 3:

file > preferences > settings

  • file (top left next to icon of visual studio code) image of where to click method 3,1

  • preferences (near bottom under auto save) image of where to click method 3,2

  • settings (the very top option) image of where to click method 3,3

Method 4:

  • Click cog icon (bottom left under the account icon/person) image of where to click method 4,1

  • Settings (second option from top) image of where to click method 4,2


Now you should be in settings and it should look like this:

UNLESS you did method 1 in how to get to settings, And you clicked on the button that said settings on the error message, I cannot include anymore pictures, read carefully.

2) Get to JSON file to resolve error:

Method 1:

  • Click the underlined text that says edit in settings.json (it should be right in front of you nearly in the centre of the screen)

Method 2:

  • Click the {} or paper with the arrow suggesting turning over the paper, When hovering over it, it will say open settings (JSON) (you will find it under the minimize screen button in the top right corner of the screen)

3) Enter this code:

Method 1:

You should be using xampp because this tutorial is for that specific control panel.

Inside the main JSON brackets ({})

Add this to the end:

{
    "php.validate.executablePath": "C:/xampp/php/php.exe"
}

Method 2:

  • If using a different drive simply change the C: to whatever drive it is e.g. D:

  • If still getting the error change the path so it works for you, you want to locate the php.exe or just PHP and the file class will be "application",

Then route the exe to the PHP using the path you took to locate the php.exe "application"

Remember you start at your drive so it should always start with C: (the drive you saved the xampp in)

4) Now save and close Visual Studio Code and re-open it


I hoped this helped if not I am sorry but this worked for me after looking around for a bit.