Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AlexanderKim's avatar

Is there prettier alternative for PHP in VScode

In VSCode there's a function "Format document", when i work on a clientside code in TS/JS - prettier works awesome, it corrects indentation, string lines, semicolons. But i cannot find something similar for PHP. Can somebody advice a good plugins, if it does exists.

0 likes
8 replies
janosk's avatar

Hi @alexanderkim I am not saying one is better than the other, but if you do not have the PHP Intelephense (with "ph" in the middle, there is another similar), then you should definietly give it a try, not just for formatting. Even Jeff recommends it in his VS Code serie. https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client

Another candidate might be the PHP-CS-Fixer https://marketplace.visualstudio.com/items?itemName=higoka.php-cs-fixer

Although i never had to give it a try after Intelephense.

2 likes
AlexanderKim's avatar

@janosk wait, is php inteliphense does the same work as php cs fixer? I have installed them both, but none of them does the job as prettier, for example, if i omit semicolon, then formatting a document won't put a semicolon there.

janosk's avatar

It does a lot more than php cs fixer, but in my opinion it has decent format capabilites. You weren't that specific about the semicolon before :) and to be honest i never used it for exactly that, therefore sadly i can't confirm if it has that ability at the moment.

Snapey's avatar

in js, having semicolon is a matter of preference (or team policy) so its common that a code style fixer will tidy that up.

PHP on the otherhand, the semicolons are mandatory, and its critical where they are placed. I'd be surprised if a fixer took care of this.

mdl's avatar

Install the Prettier extension for VSCode. Asuming you have nodejs installed, in your project run npm install --save-dev prettier @prettier/plugin-php. Enjoy.

1 like
secondman's avatar

I've got a bunch of mangled code from using php_cs_fixer, I have PHPIntelliphense installed and it seems to be correcting these issues, but of course one page at a time.

Is there a way to run this on my entire app directory in one go? I'd also probably use husky and lint-staged moving forward to keep it formatted before it gets pushed. But for now I need to clean up an entire app.

Thanks.

Please or to participate in this conversation.