How to make prettier (php) to work with VS Code

Viewed 2144

I have prettier installed on VS code but it does not seem to have any functionality. I installed Prettier - Code formatter (6.4.0) through VS code extensions, I am using the latest version of VScode and there are no updates available.

Both the format on save and cmd-shift-p no nothing for .php files but works perfectly for .js files.

My VS code settings.json file look like this:

{
"editor.codeActionsOnSave": null,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}

This is the only VS code extension I have installed, so it is not a compatibility issue with another VS code extension, however I did also install the plugin-php formatter globally using:

npm install --global prettier @prettier/plugin-php
1 Answers

Try installing the PHP formatter locally, like this:

npm install --save-dev prettier @prettier/plugin-php
Related