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
October 7, 2017
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
March 23, 2023
🌐
JetBrains
jetbrains.com › help › phpstorm › prettier.html
Prettier | PhpStorm Documentation
November 24, 2025 - Learn more from Configuring a local Node.js interpreter. Make sure the JavaScript and TypeScript and Prettier required plugins are enabled on the Settings | Plugins page, tab Installed. For more information, refer to Managing plugins.
🌐
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
🌐
Meh
meh.dev › phpstyle-making-php-prettier
PHPStyle: Making PHP Prettier - meh.dev
November 26, 2018 - PHP_CodeSniffer is the original style tool for PHP, it’s been around since 2009! Configured with a phpcs.xml file or a phpcs.xml.dist file, this project is highly un-opinionated.
🌐
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:
🌐
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 ...
🌐
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 - 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.
🌐
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" }
🌐
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 › 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.
🌐
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
🌐
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...
🌐
GitHub
github.com › lots0logs › prettier-plugin-php-wp
GitHub - lots0logs/prettier-plugin-php-wp: Prettier PHP Plugin That Enforces WordPress Coding Standards · GitHub
yarn add --dev prettier @prettier/plugin-php # or globally yarn global add prettier @prettier/plugin-php
Author   lots0logs
🌐
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 - By following this guide, you'll be able to streamline your PHP development process and ensure your code looks sharp and professional. Let’s dive in and unlock the full potential of code formatting in VSCode! 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 ...