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
npm install --save-dev prettier @prettier/plugin-php # or globally (pending https://github.com/prettier/prettier/issues/15141) npm install --global prettier @prettier/plugin-php · Create or modify your prettier configuration file to activate ...
Starred by 1.8K users
Forked by 138 users
Languages   PHP 67.1% | JavaScript 32.9%
🌐
npm
npmjs.com › package › @prettier › plugin-php
prettier/plugin-php
July 16, 2025 - npm install --save-dev prettier @prettier/plugin-php # or globally (pending https://github.com/prettier/prettier/issues/15141) npm install --global prettier @prettier/plugin-php · Create or modify your prettier configuration file to activate ...
      » npm install @prettier/plugin-php
    
Published   Jul 16, 2025
Version   0.24.0
Author   Lucas Azzola
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
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
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
August 22, 2019
prettier does not seem to respect printWidth

Run prettier from the command line. If that does what you expect then you can narrow down from there by slowing removing parts of your neovim config.

More on reddit.com
🌐 r/neovim
6
1
May 16, 2024
🌐
JetBrains
jetbrains.com › help › phpstorm › prettier.html
Prettier | PhpStorm Documentation
November 24, 2025 - PhpStorm adds this action as soon as you install Prettier as a dependency in your project or globally on your computer. You can configure Prettier to reformat specific files every time such file is changed and the changes are saved automatically or manually, refer to Run Prettier automatically ...
🌐
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
🌐
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).
🌐
Loilo
loilo.github.io › prettier-php-playground
Prettier PHP Playground
A playground for the experimental Prettier PHP plugin
Find elsewhere
🌐
Assertchris
assertchris.dev › articles › 2024-03-25-prettier-php-code
Prettier PHP Code | Christopher Pitt
March 25, 2024 - Now, when I open the command palette, and go to "Tasks: Run Task"; I see "Format PHP" as an option. I can run the task and it'll format the current file. There are more docs, if you can't get your task running the way you want. Finally, we need a way for this task to be run whenever we save. I installed an extension that will run tasks by label, for matching extensions. I just needed to add the following to config:
🌐
Made With Love
madewithlove.com › blog › software-engineering › 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).
🌐
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 - Prettier itself supports quite a lot of languages such as JavaScript, TypeScript, JSX, Angular, Vue, CSS, HTML, JSON, GraphQL, and others. Then you create settings.json using Ctrl + Shift + P then search for "open user settings". Select the (JSON) one. Then the settings.json file will open. So here add the following configuration: "[php]": { "editor.defaultFormatter": "bmewburn.vscode-intelephense-client" }
🌐
UNPKG
unpkg.com › @prettier › plugin-php@0.14.0 › README.md
Untitled
Remember that even when using a bundler, you still have to use the standalone builds: ```js import prettier from "prettier/standalone"; import phpPlugin from "@prettier/plugin-php/standalone"; prettier.format(YOUR_CODE, { plugins: [phpPlugin], parser: "php" }); ``` ## Configuration Prettier ...
🌐
Prettier
prettier.io › docs › configuration.html
Configuration File · Prettier
July 5, 2023 - Here’s an annotated description of how different properties map to Prettier’s behavior: # Stop the editor from looking for .editorconfig files in the parent directories # root = true [*] # Non-configurable Prettier behaviors charset = utf-8 insert_final_newline = true # Caveat: Prettier won’t trim trailing whitespace inside template strings, but your editor might.
🌐
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
August 22, 2019 - If you add .blade.php as a new extension for HTML, then the "normal" prettier HTML formatting should kick in... Edit: Assuming you have prettier set up for HTML formatting to begin with. I'm using "Prettier - code formatting" by Esben Peterson, along with the prettier config file I show in the post.
🌐
GitHub
github.com › php-dev › prettier-plugin-php
GitHub - php-dev/prettier-plugin-php: Prettier PHP Plugin
Bundlers like webpack, Rollup or browserify automatically recognize how to handle the PHP plugin. Remember that even when using a bundler, you still have to use the standalone builds: import prettier from "prettier/standalone"; import phpPlugin from "@prettier/plugin-php/standalone"; prettier.format(YOUR_CODE, { plugins: [phpPlugin], parser: "php" });
Author   php-dev
🌐
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.
🌐
Prettier
prettier.io › blog › 2018 › 04 › 09 › plugin-php-0.1.html
Prettier for PHP 0.1: First alpha release 🎉 · Prettier
April 9, 2018 - Instead, we identified PSR-1, PSR-2 ... this as our guide when it came to formatting our re-printed PHP code. From the experience gained with Prettier for JavaScript, we believe that offering as few configuration options as possible is one of Prettier's biggest strengt...
🌐
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 ·
🌐
Prettier
prettier.io › docs › plugins
Plugins · Prettier
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 · @prettier/plugin-pug by @Shinigami92 ·