Are there any command line (not interactive, not web-based) tools that will reformat (pretty-print) PHP and Javascript code?
Prettier is an opinionated code formatter. It 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. This plugin adds support for the PHP language to Prettier.
As of version 4.3. 0, PHP supports a new SAPI type (Server Application Programming Interface) named CLI which means Command Line Interface. As the name implies, this SAPI type main focus is on developing shell (or desktop as well) applications with PHP.
Add the extension Format HTML in PHP to Visual Studio Code. Or search in extensions with "format HTML in PHP". After reload, use Shift + Alt + F .
PHP_ Beautifier is very outdated! For a more modern approach try php-cs-fixer
Example command:
php-cs-fixer fix --rules=@PSR2 path/to/php/src
A second alternative is PHP_CodeSniffer
Example command: phpcbf --standard=PSR2 path/to/php/src
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With