This package intergates PHP Coding Standards Fixer into Emacs.
NOTICE: This package was started before I discovered https://github.com/OVYA/php-cs-fixer, which you should probably consider using if you’re reading this.
You need to have PHP-CS-Fixer (https://github.com/FriendsOfPHP/PHP-CS-Fixer) installed
If it is in your path, it should be detected automatically.
(use-package php-cs-fixer :ensure nil
:load-path "~/src/php-cs-fixer.el"
:config (setq php-cs-fixer--enable nil)) ;; disable it globally if you plan to enable it per folder
With a buffer-local hook :
(add-hook 'php-mode-hook
(lambda () (add-hook 'before-save-hook #'php-cs-fixer--fix nil 'local)))
In case you setup a before-save-hook
, you might want
to tune php-cs-fixer--enable
to control on which projects it runs.
Run php-cs-fixer--fix
to fix code style for the current buffer. In
case a .php_cs or .php_cs.dist file is found in the project root (as
guessed by php-project), it will be used.