From the official doc here: https://github.com/prettier/plugin-php for Visual Studio Code: add php to document selectors in vscode settings (settings.json)

 "prettier.documentSelectors": [
    "**/*.{js,jsx,ts,tsx,vue,html,css,scss,less,json,md,mdx,graphql,yaml,yml,php}"
  ]

and declare the php parser in prettier config file (.prettierrc) https://prettier.io/docs/en/configuration

{
    "parser": "php",
    "plugins": ["@prettier/plugin-php"]
}
Answer from Didier Corbière on Stack Overflow
🌐
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
🌐
Bordermedia
bordermedia.org › blog › using-prettier-format-php-in-vscode
Using Prettier to format PHP code in VS Code
Note: The plugin requires PHP to be installed on your system as it uses PHP's built-in tokenizer for parsing. Install the official Prettier - Code formatter extension from the VS Code marketplace.
🌐
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
🌐
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
🌐
Codethepixel
codethepixel.com › articles › Formatting-PHP-in-VSCode-Using-Prettier-and-PHP-Intelephense
CTP: Formatting PHP in VSCode Using Prettier and PHP Intelephense
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 ...
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 ·
🌐
trungpv
trungpv1601.github.io › 2020 › 01 › 04 › Using-Prettier-code-formatter-in-PHP-with-VSCode
Using Prettier code formatter in PHP with VSCode
January 4, 2020 - Using Prettier code formatter in PHP with VSCodeWhat is Prettier? https://prettier.io/ Installation1. Prettier - Code formatterInstall through VS Code extensions. Search for Prettier - Code formatter
🌐
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 20, 2017 - I don't really want to talk about ... code formatting, and the same tool can be used to format JS/PHP/HTML/JSON etc. Every time I get a new machine, I have to research how to set Prettier up for this, in VSCode....
🌐
npm
npmjs.com › package › @prettier › plugin-php
prettier/plugin-php
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.
      » npm install @prettier/plugin-php
    
Published   Jul 16, 2025
Version   0.24.0
Author   Lucas Azzola
🌐
GitHub
github.com › prettier › prettier-vscode › issues › 1059
Not working for PHP · Issue #1059 · prettier/prettier-vscode
August 23, 2019 - The extension still not working, when I try to format a php file vscode ask me to install a formatter · Install globally prettier and pretier-php (npm install --global prettier @prettier/plugin-php)
Published   Nov 15, 2019
🌐
Prettier
prettier.io › docs › editors
Editor Integration · Prettier
prettier-vscode can be installed using the extension sidebar – it’s called “Prettier - Code formatter.” Check its repository for configuration and shortcuts.
🌐
GitHub
github.com › prettier › prettier-vscode › discussions › 3184
Prettier not formatting PHP Code · prettier/prettier-vscode · Discussion #3184
I have PHP v8.2.11 currently installed and set up I installed prettier via the Extensions Tab in VS Code I ran npm install --global prettier @prettier/plugin-php After I ran npm fund as instructed from the terminal I set my formatter as Prettier ...
Author   prettier
🌐
Prettier
prettier.io › blog › 2018 › 04 › 09 › plugin-php-0.1.html
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.