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 Answer from JParkinson1991 on reddit.com
🌐
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.

🌐
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
Discussions

Format code command for PHP/HTML in Visual Studio Code - Stack Overflow
I went ahead and made an extension ... as a PHP formatter, so it will do all the HTML with js-beautify and then you can use something like PHPCS + PHPCBF to format the HTML. So it's basically, as far as I'm concerned, the best solution currently available. Format HTML in PHP on the Visual Studio Code marketplace. ... I use bmewburn.vscode-intelephe... More on stackoverflow.com
🌐 stackoverflow.com
Is there any PHP code formatter for VSCode that complies with PSR-12? - Software Recommendations Stack Exchange
Does anyone know a code style formatter that complies with the PSR-12 for Visual Studio Code? I searched the web, but I can only find some plug-ins like PHP Formatter which follows the PSR-2 which... More on softwarerecs.stackexchange.com
🌐 softwarerecs.stackexchange.com
February 29, 2020
How do you configure code formatting and linting for PHP in PHPStorm and VSCode?
Code formatting is the process of making your code more readable and consistent by applying rules for indentation, spacing, alignment, and other aspects. Code formatting can improve your code quality, reduce errors, and make collaboration easier. Both PHPStorm and VSCode have built-in code ... More on linkedin.com
🌐 linkedin.com
4
2
April 8, 2021
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
🌐
GitHub
github.com › squizlabs › PHP_CodeSniffer › discussions › 3941
vs code formatting mixed php and html · squizlabs PHP_CodeSniffer · Discussion #3941
March 5, 2024 - Adjust the settings for PHP and HTML formatting to your preference. For example: "php.format.enable": true, "php.suggest.basic": false, "editor.formatOnSave": true, // Enable format on save "editor.defaultFormatter": "esbenp.prettier-vscode", // Use Prettier as the default formatter ·
Author   squizlabs
🌐
Laravel Daily
laraveldaily.com › post › vs-code-extensions-laravel-php
Four VS Code Extensions For Laravel/PHP Projects
Laravel Pint is a code formatter specifically for Laravel. It makes sense to use it in VSCode as well. With this extension, we get a few nice features: ... While it doesn't seem like it does much, it's just nice to run Pint from the editor. You can get the extension from the VSCode Marketplace · The last extension we used is PHP...
Top answer
1 of 14
104

Update 2021-07-21

It's been more than half a decade since I first wrote this answer. The extensions to which I originally linked are abandoned, and Visual Studio Code's intrinsic PHP support hasn't improved, which is disappointing. The only decent extension still standing of which I'm aware is PHP Intelephense, which uses a freemium model: basic features are free, and a lifetime license is $12 USD as of writing.

The free version of Intelephense supports code formatting with the usual shortcuts (Alt + Shift + F on Windows and Linux, ⌥⇧F on macOS). Visual Studio Code continues to lack built-in support for PHP code formatting and will direct you to the extension marketplace if you attempt to format PHP without an appropriate extension installed.

Original answer

Visual Studio Code has pretty awesome PHP support. What it lacks is covered by extensions. A quick search reveals at least three (1, 2, and 3) that claim to support PHP formatting.

They mostly seem to use the standard shortcut of Alt + Shift + F on Windows/Linux, with varying shortcuts on Mac. If you're on Mac, give ⌥⇧F a try.

2 of 14
52

I installed

  • Prettier for HTML, CSS, and JavaScript files

  • PHP Intelephense for PHP files

I followed the instructions for each plugin but found I had to additionally edit settings.json manually in order to get them to work together.

"editor.defaultFormatter": "esbenp.prettier-vscode",
"[php]": {
  "editor.defaultFormatter": "bmewburn.vscode-intelephense-client"
}

The settings use Intelephense as the formatter for PHP files and use Prettier as the formatter for all other files.

Now I use Shift + Alt + F to format the files like everybody else.

🌐
Medium
aidilfitra.medium.com › the-ultimate-guide-to-code-formatters-plugin-in-vs-code-every-language-one-editor-3457d248b5d1
The Ultimate Guide to Code Formatters Plugin in VS Code: Every Language, One Editor | by Aidil Fitra | Medium
June 9, 2025 - From PHP to Python, Java to Rust, VS Code has formatter support to match your backend of choice. Most have official formatters supported by the language’s community. ... These formatters not only clean code — they enforce best practices and reduce merge conflicts.
Find elsewhere
🌐
Medium
thiraphat-ps-dev.medium.com › the-best-code-formatters-for-vs-code-11704e787f92
The Best Code Formatters for VS Code | by Thiraphat Phutson | Medium
June 3, 2024 - Whether you prefer the comprehensive support of Prettier, the linting and formatting capabilities of ESLint, the readability focus of Beautify, or the powerful formatting of clang-format, there is a tool that fits your needs.
🌐
Visual Studio Code
code.visualstudio.com › docs › languages › php
PHP in Visual Studio Code
November 3, 2021 - Learn about Visual Studio Code editor features (syntax highlighting, snippets, linting) and extensions for PHP.
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
PHP Formatter - Visual Studio Marketplace
December 9, 2016 - Extension for Visual Studio Code - A wrapper for the Sensiolabs PHP CS Fixer. Analyzes some PHP source code and tries to fix coding standards issues (PSR-1 and PSR-2 compatible).
🌐
Aslam Doctor
aslamdoctor.com › home › articles › php code sniffing & formatting in vscode
PHP Code Sniffing & Formatting in VSCode - Aslam Doctor
June 16, 2025 - While coding in PHP using VSCode, there are plenty of extensions that provide code formatting. Some of those are PHP Intelephense, phpfmt, and PHP Formatter. These are good extensions but don’t provide a better solution for code sniffing and formating code using PHP Standards.
🌐
DEV Community
dev.to › arafatweb › top-10-vs-code-extensions-for-php-developers-in-2024-2m08
Top 10 VS Code Extensions for PHP Developers in 2024 - DEV Community
July 1, 2024 - Description: PHP CS Fixer helps you format your PHP code to follow standard coding conventions automatically.
🌐
Devsense
docs.devsense.com › vscode › formatting
Code Formatting - PHP Tools for Visual Studio - Documentation
Formatter will help you keep your PHP code in VS Code clean and maintain the preferred code style like PSR-12, PSR-2, Allman and K&R.
🌐
Visual Studio Marketplace
marketplace.visualstudio.com › items
PHP Sniffer & Beautifier - Visual Studio Marketplace
December 28, 2025 - Extension for Visual Studio Code - PHP Sniffer & Beautifier for Visual Studio Code
🌐
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 ·
🌐
GitHub
github.com › vysker › vscode-php-formatter
GitHub - vysker/vscode-php-formatter: Visual Studio Code extension. A wrapper for the Sensiolabs PHP CS Fixer. Analyzes some PHP source code and tries to fix coding standards issues (PSR-1 and PSR-2 compatible).
After installing as an extension with Visual Studio Code, this extension automatically formats your PHP code, in accordance with PSR-0, PSR-1, PSR-2 or Symfony style conventions. Format current selection only, or the whole file. Trigger formatting with custom keybindings or actions.
Starred by 90 users
Forked by 12 users
Languages   TypeScript 89.5% | JavaScript 10.5% | TypeScript 89.5% | JavaScript 10.5%
🌐
YouTube
youtube.com › watch
PHP-CS-Fixer + VSCode = ✨ Automate Code Formatting, Elevate PHP Standards (In-depth Tutorial) - YouTube
In this video, we'll explore the ins and outs of PHP-CS-Fixer, a powerful tool that can significantly enhance your PHP codebase by automating the fixing of c...
Published   February 5, 2024