I was recently asked if Emacs supports formatting PHP code. There are options for other languages, but nothing in the standard release for beautifying PHP.

php-beautifier.el is an extension I created that integrates PHP_Beautifier into Emacs. It can be used to format an entire buffer or a single region.

It also supports phpcbf for fixing coding standards issues.

php-beautifier.el in action

There are two main functions in the extension:

php-beautifier-format-buffer beautifies the entire buffer in one go:

Formatting an entire buffer

php-beautifier-format-region formats a region instead.

Note that PHP_Beautifer checks for a starting <?php tag, so it won't format a region that doesn't contain one.

Full setup and usage instructions are available on the php-beautifier.el project page.