Format PHP code in Emacs using PHP_CodeSniffer's phpcbf.
You can install
phpcbf.el from MELPA with package.el
M-x package-install phpcbf).
And you can also install it with el-get.
If called interactively, the current buffer is formatted according to
Default standard is "PEAR".
Add this to init file to run phpcbf on the current buffer when saving:
(add-hook 'php-mode-hook 'phpcbf-enable-on-save)
(require 'phpcbf) (custom-set-variables '(phpcbf-executable "/usr/local/bin/phpcbf") '(phpcbf-standard "PSR2")) ;; Auto format on save. (add-hook 'php-mode-hook 'phpcbf-enable-on-save)
phpcbf command (default is called
The name or path of the coding standard to use (default is "PEAR").
How to check installed standards:
$ phpcbf -i The installed coding standards are PSR1, PHPCS, Zend, PEAR, PSR2, Squiz and MySource
And more your custom standards. See here