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.
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.
On Mac Os:
In the vscode settings (JSON view) extend the ^^ above option with the Mac Os PHP path:
Copy "phpfmt.php_bin": "/usr/bin/php"
Cheers
Videos
On the the menu go to Preferences > Package Settings > phpfmt > Settings - User
Edit the file that will open in result of the previous action.
Specify the "php_bin" according to your php binary location,
It should contain something like this:
{
"enable_auto_align": false,
"indent_with_space": true,
"passes":
[
],
"php_bin": "/Applications/MAMP/bin/php/php5.5.10/bin/php",
"psr1": true,
"psr2": true,
"version": 2
}
This answer is for newer version.
SublimeText 3 and PHPfmt 4
On the the menu go to Preferences > Package Settings > phpfmt > Settings - User and add below code, please make sure PHP >= 5.6 is installed on path C:/php/php.exe or you can replace with your PHP.exe path below:
{
"version": 4,
"php_bin":"C:/php/php.exe",
"format_on_save":true,
}
» npm install vscode-phpfmt
You can use the following settings that i use for my development env, would be closest to what you are looking for.
Add the following into your settings.json in VSCode.
{
"phpfmt.php_bin": "php",
"phpfmt.passes": [
"AlignPHPCode",
"AlignTypeHint",
"AlignDoubleArrow",
"AddMissingParentheses",
"ConvertOpenTagWithEcho",
"DocBlockToComment",
"IndentTernaryConditions",
"JoinToImplode",
"PSR2KeywordsLowerCase",
"PSR2LnAfterNamespace",
"PSR2CurlyOpenNextLine",
"PSR2ModifierVisibilityStaticOrder",
"PSR2SingleEmptyLineAndStripClosingTag",
"ReindentSwitchBlocks",
"RemoveUseLeadingSlash",
"StripExtraCommaInArray",
"SpaceBetweenMethods",
],
"phpfmt.exclude": [
"ReindentComments",
"StripNewlineWithinClassBody"
],
"phpfmt.psr2": false
}
For double array formatting you will find in settings like the attached image.

And if you want to do it in settings.json, add AlignPHPCode into phpfmt.passes array.

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.

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 sayopen 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.exeor justPHPand 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.