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
Discussions

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
What is the most common PHP code formatter?
php-cs-fixer https://github.com/PHP-CS-Fixer/PHP-CS-Fixer I do disagree on code standards being enforced in the IDE. My view is they absolutely need to be enforced at the project level to ensure consistency of code standard throughout that project. The IDE should be capable of configuring itself based on project owned configurations (this is the case when using php-cs-fixer). Edit: To your point of having an opinionated standard set out of the box. PSR12 https://www.php-fig.org/psr/psr-12/ . A rulset for this standard already exists in php-cs-fixer. Edit 2: For absolute transparency, there is also another popular capable of doing everything I mentioned above - https://github.com/squizlabs/PHP_CodeSniffer More on reddit.com
🌐 r/PHPhelp
19
7
August 1, 2024
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 20, 2017
🌐
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.
Author   prettier
🌐
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 ...
🌐
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.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-format-code-with-prettier-in-visual-studio-code
Format Code with Prettier in Visual Studio Code: Setup Guide | DigitalOcean
August 1, 2025 - Learn how to format code with Prettier in Visual Studio Code. This guide walks you through installing, configuring, and using Prettier for code formatting.
Find elsewhere
🌐
Prettier
prettier.io
Prettier · Opinionated Code Formatter · Prettier
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 · Got more?Send a PR ·
🌐
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...
Published   May 06, 2021
🌐
Assertchris
assertchris.dev › articles › 2024-03-25-prettier-php-code
Prettier PHP Code | Christopher Pitt
March 25, 2024 - I am so tired of looking the same thing up, so I'm going to write an article about how to automatically format PHP code in VS Code.
🌐
Reddit
reddit.com › r/phphelp › what is the most common php code formatter?
r/PHPhelp on Reddit: What is the most common PHP code formatter?
August 1, 2024 -

I found three code formatters for PHP.

  • Prettier (With PHP Plugin)

  • PrettyPHP (https://github.com/lkrms/vscode-pretty-php)

  • phpfmt (https://github.com/kokororin/vscode-phpfmt)

I was able to setup Prettier with the PHP plugin but the setup is not ideal since I have to install prettier and the prettier PHP plugin from NPM into the project every single time which is not the case when using Prettier VSCode extension with HTML, JS and CSS. I do like how Prettier has its own configuration .prettierrc files and it allows you to set a standard format for a project you are collaborating with others, however I believe formatting should be done in the IDE such as using a VSCode extension and this is the case with the Prettier extension for HTML, JS and CSS but not for PHP since it requires NPM packages.

The other two do not look popular. Am I missing something? I would like to have a standard format or be able to have an opinionated format setup like Prettier for JS but for PHP.

🌐
Made With Love
madewithlove.com › blog › using-prettier-in-php
Using Prettier in PHP
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).
🌐
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
🌐
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