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
It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary. This plugin adds support for the PHP language to Prettier.
Author   prettier
🌐
Prettier
prettier.io › docs › plugins
Plugins · Prettier
@prettier/plugin-php · @prettier/plugin-pug by @Shinigami92 · @prettier/plugin-ruby · @prettier/plugin-xml · prettier-plugin-apex by @dangmai · prettier-plugin-astro by @withastro contributors · prettier-plugin-bigcommerce-stencil by @phoenix128 · prettier-plugin-elm by @giCentre ·
Discussions

html - VSCode Prettier not formatting PHP - Stack Overflow
And from the plugin description it looks you still don't need to. However, I didn't test it in my actual VSCode setup. 2023-09-18T14:12:40.523Z+00:00 ... This works if you remove --global and install it locally. 2023-03-10T11:22:45.207Z+00:00 ... Sadly there is no support for .php files with HTML: https://github.com/prettier... More on stackoverflow.com
🌐 stackoverflow.com
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 make prettier (php) to work with VS Code - Stack Overflow
npm install --global prettier @prettier/plugin-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
🌐
SourceForge
sourceforge.net › projects › prettier-php-plugin.mirror
Prettier PHP Plugin download | SourceForge.net
It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary. This plugin adds support for the PHP language to Prettier.
🌐
Phpqa
phpqa.io › projects › prettier-php-plugin.html
Prettier PHP plugin | PHP Quality Assurance
Prettier PHP plugin adds support for the PHP language to Prettier, an opinionated code formatter.
🌐
Prettier
prettier.io
Prettier · Opinionated Code Formatter · Prettier
Community Plugins · Apex · 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 ·
🌐
Bordermedia
bordermedia.org › blog › using-prettier-format-php-in-vscode
Using Prettier to format PHP code in VS Code
June 19, 2025 - However, PHP is not included in the core supported languages. Fortunately, the community has created @prettier/plugin-php, a plugin that brings Prettier's formatting capabilities to PHP code.
🌐
Peter Babič
peterbabic.dev › blog › prettier-php-plugin-in-vim
Peter Babič - Prettier PHP plugin in vim
July 22, 2021 - I use coc-prettier in my current neovim setup, especially for it's ease of use on Markdown (prose-wrap anyone?) and Javascript. PHP is however not supported by prettier out of the box, and is rather supplied as a community maintained plugin under prettier/plugin-php.
Find elsewhere
🌐
Prettier
prettier.io › blog › 2018 › 04 › 09 › plugin-php-0.1
Prettier for PHP 0.1: First alpha release 🎉 · Prettier
April 9, 2018 - After more than 200 merged pull requests since mid December 2017, we're happy to announce the first alpha release of Prettier for PHP. In this blog post, we'd like to give a short overview of how the plugin works, its philosophy, and what to expect in the future.
🌐
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.

🌐
npm
npmjs.com › package › @prettier › plugin-php › v › 0.10.2
@prettier/plugin-php - npm
February 18, 2019 - Prettier PHP Plugin. Latest version: 0.24.0, last published: 5 months ago. Start using @prettier/plugin-php in your project by running `npm i @prettier/plugin-php`. There are 67 other projects in the npm registry using @prettier/plugin-php.
      » npm install @prettier/plugin-php
    
Published   Jul 16, 2025
Version   0.10.2
Author   Lucas Azzola
🌐
JetBrains
jetbrains.com › help › phpstorm › prettier.html
Prettier | PhpStorm Documentation
For more information, refer to Managing plugins. Open the embedded Terminal (Alt+F12) . ... Learn more about installation modes from the Prettier official website. PhpStorm enables Prettier and adds the Reformat with Prettier action as soon as you install it as described above.
🌐
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
🌐
UNPKG
unpkg.com › @prettier › plugin-php
prettier/plugin-php
Prettier PHP Plugin · github.com/prettier/prettier-php · prettier/prettier-php · 1 folder, 5 files · github.com/prettier/prettier-php · prettier/prettier-php · Latest: 0.24.0 ·
🌐
jsDelivr
jsdelivr.com › package › npm › @prettier › plugin-php
@prettier/plugin-php CDN by jsDelivr - A CDN for npm and GitHub
July 16, 2025 - A free, fast, and reliable CDN for @prettier/plugin-php. Prettier PHP Plugin
Published   Feb 17, 2018