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
Prettier is an opinionated code formatter. 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.
Author   prettier
🌐
Prettier
prettier.io › docs › plugins
Plugins · Prettier
await prettier.format("code", { parser: "foo", plugins: ["prettier-plugin-foo"], }); The Configuration File: { "plugins": ["prettier-plugin-foo"] } Strings provided to plugins are ultimately passed to import() expression, so you can provide a module/package name, a path, or anything else import() takes. @prettier/plugin-php ·
🌐
Phpqa
phpqa.io › projects › prettier-php-plugin.html
Prettier PHP plugin | PHP Quality Assurance
Prettier 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. Note: this plugin can also be integrated with php-cs-fixer.
🌐
npm
npmjs.com › package › @prettier › plugin-php
prettier/plugin-php
Prettier is an opinionated code formatter. 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.
      » npm install @prettier/plugin-php
    
Published   Jul 16, 2025
Version   0.24.0
Author   Lucas Azzola
🌐
SourceForge
sourceforge.net › projects › prettier-php-plugin.mirror
Prettier PHP Plugin download | SourceForge.net
Prettier PHP Plugin. Prettier is an opinionated code formatter. 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.
🌐
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
🌐
Bordermedia
bordermedia.org › blog › using-prettier-format-php-in-vscode
Using Prettier to format PHP code in VS Code
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.
Find elsewhere
🌐
GitHub
github.com › lots0logs › prettier-plugin-php-wp
GitHub - lots0logs/prettier-plugin-php-wp: Prettier PHP Plugin That Enforces WordPress Coding Standards · GitHub
Prettier is an opinionated code formatter. 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.
Author   lots0logs
🌐
Prettier
prettier.io › blog › 2018 › 04 › 09 › plugin-php-0.1
Prettier for PHP 0.1: First alpha release 🎉 · Prettier
April 9, 2018 - Today, you can try the plugin from the command line by following the instructions in the README. Plugin support in your favorite editor might not work yet, though (see the related issues for VS Code, Atom and Vim). Also, the PHP plugin is not integrated in Prettier's playground yet.
🌐
npm
npmjs.com › package › @prettier › plugin-php › v › 0.10.2
Prettier PHP Plugin
" Prettier for PHP function PrettierPhpCursor() let save_pos = getpos(".") %! prettier --stdin --parser=php call setpos('.', save_pos) endfunction " define custom command command PrettierPhp call PrettierPhpCursor() " format on save autocmd ...
      » npm install @prettier/plugin-php
    
Published   Jul 16, 2025
Version   0.10.2
Author   Lucas Azzola
🌐
GitHub
github.com › prettier › plugin-php › tree › v0.19.7
GitHub - prettier/plugin-php at v0.19.7
Prettier is an opinionated code formatter. 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.
Starred by 1.8K users
Forked by 137 users
Languages   PHP 67.1% | JavaScript 32.9%
🌐
GitHub
github.com › php-dev › prettier-plugin-php
GitHub - php-dev/prettier-plugin-php: Prettier PHP Plugin
array_map( function ($arg1, $arg2) use ($var1, $var2) { return $arg1 + $arg2 / ($var + $var2); }, array( "complex" => "code", "with" => "inconsistent", "formatting" => "is", "hard" => "to", "maintain" => true ) ); You can give the plugin a try in our playground! ... yarn add --dev prettier @prettier/plugin-php # or globally yarn global add prettier @prettier/plugin-php
Author   php-dev
🌐
Made With Love
madewithlove.com › blog › using-prettier-in-php
Using Prettier in PHP
June 6, 2024 - npm install --global prettier @prettier/plugin-php · Once Prettier is installed, you can quickly try it out on one or more files by invoking it directly (e.g. prettier somefile.php or prettier src/**.php). An example with some badly formatted code:
🌐
GitHub
github.com › prettier › plugin-php › blob › main › CONTRIBUTING.md
plugin-php/CONTRIBUTING.md at main · prettier/plugin-php
{ "type": "node", "request": "launch", "name": "Prettify test.php", "skipFiles": [ "<node_internals>/**" ], "program": "${workspaceRoot}/node_modules/.bin/prettier", "args": ["--plugin=.", "--parser=php", "test.php"], "cwd": "${workspaceRoot}", ...
Author   prettier
🌐
UNPKG
unpkg.com › @prettier › plugin-php@0.14.0 › README.md
Unpkg
Formatting of files that contain mixed PHP and HTML is still considered unstable - please see [open issues with the tag "inline"](https://github.com/prettier/plugin-php/issues?q=is:issue+is:open+sort:updated-desc+label:inline) for details. If you want to use the plugin in production, we recommend limiting its scope to pure PHP files. ### Input ```php array_map(function($arg1,$arg2) use ( $var1, $var2 ) { return $arg1+$arg2/($var+$var2); }, array("complex"=>"code","with"=>"inconsistent","formatting"=>"is", "hard" => "to", "maintain"=>true)); ``` ### Output ```php array_map( function ($arg1, $ar
🌐
CodeSandbox
codesandbox.io › examples › package › @prettier › plugin-php
prettier/plugin-php examples
Use this online @prettier/plugin-php playground to view and fork @prettier/plugin-php example apps and templates on CodeSandbox.
🌐
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.