Core prettier does not support PHP1, and thus neither does the plugin for VSCode/VSCodium. Luckily the designers of prettier seems to have thought of this and implemented a plugin system2.

According to the prettier-vscode repo, all you need to do to use a plugin is to add it and prettier to your package.json3

So for php support your package.json would need to contain:

{
  "devDependencies": {
    "@prettier/plugin-php": "0.14.3",
    "prettier": "2.0.5"
  }
}
Answer from fredrik on Stack Overflow
🌐
GitHub
github.com › prettier › plugin-php
GitHub - prettier/plugin-php: Prettier PHP Plugin · GitHub
For example, if you are using PHP 7.4, but the plugin is set to PHP 8.3, it will produce code that uses features not available in PHP 7.4. A comment // prettier-ignore will exclude the next node in the abstract syntax tree from formatting. ... The official prettier plugin for vscode supports plugins since Version 1.10.0.
Starred by 1.8K users
Forked by 138 users
Languages   PHP 67.1% | JavaScript 32.9%
Discussions

Is there a way to prettify PHP code using VS Code?
One option is the prettier-php plugin. If you have the Prettier extension and install the prettier-php plugin package in the project, the Prettier extension will use it. https://github.com/prettier/prettier-php More on reddit.com
🌐 r/vscode
4
3
September 11, 2021
How to install Prettier PHP Plugin in Visual Studio Code
Hello, I am using Visual Studio Code for editing .php files. How can I set up Prettier plugin to format php in vs code. I tried to follow README.md but, I am not able to activate the code formattin... More on github.com
🌐 github.com
21
May 6, 2021
How to make prettier (php) to work with VS Code - Stack Overflow
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 ... More on stackoverflow.com
🌐 stackoverflow.com
Formatting PHP code in vscode, using prettier, on save

No one should ever format on save, on projects where you work in a team, it will be an never ending whitespace war. And it will seriously pollute your VCS diff's with unrelated whitespace changes, and potentially create conflicts along the way. Please don't.

The only valid use case of reformatting on save is when it's a project requirement, everyone uses the same tooling, editor, and formatting rules. Under any other scenario, please don't.

More on reddit.com
🌐 r/PHP
27
24
October 7, 2017
🌐
DEV Community
dev.to › ngobrolinit › prettier-for-php-file-formats-in-vscode-104o
Prettier for PHP File Formats in VSCode - DEV Community
March 18, 2024 - The solution is to use the settings.json configuration file in VSCode to set the PHP language using PHP Intelephense. Now go to settings and change Default Formatter to Prettier. Why Prettier?
🌐
GitHub
github.com › prettier › plugin-php › issues › 1721
How to install Prettier PHP Plugin in Visual Studio Code · Issue #1721 · prettier/plugin-php
May 6, 2021 - Hello, I am using Visual Studio Code for editing .php files. How can I set up Prettier plugin to format php in vs code. I tried to follow README.md but, I am not able to activate the code formattin...
Author   alexbalak21
🌐
Codethepixel
codethepixel.com › articles › Formatting-PHP-in-VSCode-Using-Prettier-and-PHP-Intelephense
CTP: Formatting PHP in VSCode Using Prettier and PHP Intelephense
June 15, 2025 - 1. Install and enable the Prettier Extension in VS Code ... { ... //other config "[php]": { "editor.formatOnSave": true, "editor.defaultFormatter": "bmewburn.vscode-intelephense-client" }, "editor.linkedEditing": true ...
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
PHP Formatter - pretty-php - Visual Studio Marketplace
Extension for Visual Studio Code - The opinionated PHP code formatter, now with full PHP 8.4 support
Find elsewhere
🌐
Bordermedia
bordermedia.org › blog › using-prettier-format-php-in-vscode
Using Prettier to format PHP code in VS Code
June 19, 2025 - Learn how to use Prettier to format PHP code in VS Code using the @prettier/plugin-php community plugin. Complete setup guide with configuration examples and troubleshooting tips.
🌐
Prettier
prettier.io
Prettier · Opinionated Code Formatter · Prettier
Elm (via elm-format) Java · PHP · Ruby · Rust · TOML · XML · And more... prettier-js prettier.el Apheleia · espresso-prettier · Prettier Prettier⁺ · JsPrettier · vim-prettier neoformat ALE coc-prettier · JavaScriptPrettier · prettier-vscode · Built-in support ·
🌐
npm
npmjs.com › package › @prettier › plugin-php
prettier/plugin-php
July 16, 2025 - For example, if you are using PHP 7.4, but the plugin is set to PHP 8.3, it will produce code that uses features not available in PHP 7.4. A comment // prettier-ignore will exclude the next node in the abstract syntax tree from formatting. ... The official prettier plugin for vscode supports plugins since Version 1.10.0.
      » npm install @prettier/plugin-php
    
Published   Jul 16, 2025
Version   0.24.0
Author   Lucas Azzola
🌐
YouTube
youtube.com › watch
Installing and setting up PHP code formatter extension or php cs fixer on Visual Studio Code - YouTube
Installing and setting up PHP code formatter extension or php cs fixer on Visual Studio Code:Follow this article:https://medium.com/@armorasha/php-cs-fixer-h...
Published   September 15, 2021
🌐
trungpv
trungpv1601.github.io › 2020 › 01 › 04 › Using-Prettier-code-formatter-in-PHP-with-VSCode
Using Prettier code formatter in PHP with VSCode
March 18, 2024 - Visual Studio Code Market Place: Prettier - Code formatter · You need to install @prettier/plugin-php in folder vscode extention: cd ~/.vscode/extensions/esbenp.prettier-vscode-3.18.0
🌐
Assertchris
assertchris.dev › articles › 2024-03-25-prettier-php-code
Prettier PHP Code | Christopher Pitt
March 25, 2024 - If you're a firm adherent to PSR-2/12, this next bit won't be that useful to you. I have been using Prettier to format my code, because it is easy to use and integrates with everything in JS-land. It's a little less common seeing it used in PHP projects, but here goes...
🌐
Reddit
reddit.com › r/php › formatting php code in vscode, using prettier, on save
r/PHP on Reddit: Formatting PHP code in vscode, using prettier, on save
October 7, 2017 - I don't really want to talk about that decision, here, except to say that on team projects or open source things I do tend to use PSR-2. For smaller projects, I like using prettier because I think the tooling is superior to the PHP alternatives for code formatting, and the same tool can be used to format JS/PHP/HTML/JSON etc. Every time I get a new machine, I have to research how to set Prettier up for this, in VSCode.
🌐
GitHub
github.com › r1pped › prettier-vscode-php
GitHub - r1pped/prettier-vscode-php: Visual Studio Code extension for Prettier with PHP support
November 24, 2025 - Visual Studio Code extension for Prettier with PHP support - r1pped/prettier-vscode-php
Author   r1pped
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 1059
Not working for PHP · Issue #1059 · prettier/prettier-vscode
April 9, 2018 - 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
Author   jmperro
🌐
Made With Love
madewithlove.com › blog › using-prettier-in-php
Using Prettier in PHP - madewithlove
June 6, 2024 - Most of the time, it will fix the latter, in very PHP specific ways, but will do very little for the former besides a few blank lines and indentation rules. Most of the time Prettier would be added to the project’s package.json, but since we want to use it in a PHP project we’ll install it globally through NPM (or Yarn if you want).
🌐
GitHub
github.com › prettier › prettier-vscode › discussions › 3184
Prettier not formatting PHP Code · prettier/prettier-vscode · Discussion #3184
I have PHP v8.2.11 currently installed and set up I installed prettier via the Extensions Tab in VS Code I ran npm install --global prettier @prettier/plugin-php After I ran npm fund as instructed from the terminal I set my formatter as Prettier under my language settings in VS Code.
Author   prettier