Hello to all!
I've the latest version of the extension in vscode.
I've installed the prettier/plugin-php on the project folder.
I've restarted vscode several times.
The extension still not working, when I try to format a php file vscode ask me to install a formatter
Prettier should format the document
VSCode notification: "There is no installed formatter for php files"
VS Code Version: 1.40.1
Prettier & Prettier Plugin Version: Prettier: 1.19.1, Pretier/plugin-php: 0.11.2, prettier/prettier-vscode: 3.6.0
OS and version: Windows 10
Guess we're running in cycles here 馃榿 See https://github.com/prettier/prettier-vscode/issues/1055
Evilebot Tnawi @evilebottnawi ask me to report an issue here.
Before plugin works fine, after latest update is it not work, I didn鈥檛 investigate why, but I think the problem is here
I confirm normal install not work with vscode on windows version
Manual install prettier plugin on vscode
cd C:\Users\%username%\.vscode\extensions\esbenp.prettier*
yarn add --dev @prettier/plugin-php
I can recommend PHP Intelephense bmewburn.vscode-intelephense-client which has built in formatting, and is by far the best PHP extension. It had a huge amount of updates lately after the author took a years break, he removed the nag screen that stopped people using it, now it should do everything you might need it to.
@mean-cj You definitely need to install both prettier and the plugins:
yarn add --dev prettier @prettier/plugin-php
I will try to repro this tonight when i can get on my windows machine.
Hello @ntotten
try prettier/prettier-vscode not format code if add prettier @prettier/plugin-php on global
yarn global add prettier @prettier/plugin-php
Adding prettier plugin-php with yarn on the prettier extension folder works fine!
@mean-cj Have you tried installing prettier in your project? Installing modules globally is not supported. Also installing modules in the extension folder is really not a good idea. That is going to get overwritten every time the extension gets updated.
@mean-cj You definitely need to install both prettier and the plugins:
yarn add --dev prettier @prettier/plugin-php
where exactly do I type this? (noob)
OS: macOS Catalina
VSCode: 1.40.2
I had the same problem. I had installed both prettier and @prettier/plugin-php globally.
I had to install both locally. It's working now.
Also make sure you set the default formatter for php as prettier
"[php]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
@mean-cj You definitely need to install both prettier and the plugins:
yarn add --dev prettier @prettier/plugin-phpwhere exactly do I type this? (noob)
Open a command prompt in your project directory (press Ctrl + ` in vscode)
copy the command and press enter!
I鈥檒l try to work on global module support soon. This seems to be a fairly common request.
I added global module resolution in version 3.13.0. Please try it out and let me know if you see any issues.
@ntotten still not work with yarn global add prettier @prettier/plugin-php on Windows 10
Please do not install prettier globally, different versions of prettier can do different format (same for plugins)
Not working for me, I have the packages installed locally, in package.json:
"devDependencies": {
"@prettier/plugin-php": "^0.14.0",
"prettier": "^2.0.5"
},
VSCode About:
Version: 1.44.2
Commit: ff915844119ce9485abfe8aa9076ec76b5300ddd
Date: 2020-04-16T17:07:18.473Z (2 wks ago)
Electron: 7.1.11
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.4.0
I figured out what was going on. In .prettierrc I had my parser set to Babel, so it was attempting to parse PHP as Babel, which failed obviously.
Solution: delete the following line from .prettierrc
{
// ...
"parser": "babel",
// ...
}
Was having trouble with this exact issue. The culprit in my case was a misconfigured setting in the settings.json file (on mac, the settings config file is located in ~/Library/Application Support/Code/User)
The settings.json config file required the correct property "php.validate.executablePath". The value to be set to this property may vary depending on the PHP version you're using.
To get the correct path of your PHP executable on a mac, open a new terminal window (Cmd + Spacebar and write terminal) and type which php. The returned value should match the config property value.
settings.json example:
{
// your other settings
"php.validate.executablePath": "/Applications/MAMP/bin/php/php7.3.8/bin/php"
}
Also make sure you set the default formatter for php as prettier
"[php]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
for me work this "php": { "editor.defaultFormatter": "esbenp.prettier-vscode" },
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
OS: macOS Catalina
VSCode: 1.40.2
I had the same problem. I had installed both prettier and @prettier/plugin-php globally.
I had to install both locally. It's working now.
Also make sure you set the default formatter for php as prettier
"[php]": { "editor.defaultFormatter": "esbenp.prettier-vscode" },