Minimalist PHP-CS-Fixer integration for Emacs
php-cs-fixer.el
is a simple Emacs package that integrates PHP CS Fixer into your Emacs workflow for PHP development. This package allows you to automatically format your PHP code according to specified coding standards every time you save a PHP file.
- Run PHP CS Fixer on Current Buffer: The
run-php-cs-fixer-on-buffer
function formats the current PHP buffer and updates it with the fixed content. - Automatic Formatting on Save: The
add-php-cs-fixer-on-save
function hooks into thebefore-save-hook
, ensuring that PHP CS Fixer runs every time you save a PHP file.
-
Ensure you have PHP CS Fixer installed on your system and accessible in your PATH.
-
Copy
php-cs-fixer.el
to your Emacsload-path
. -
Add the following to your Emacs configuration:
(require 'php-cs-fixer)
- Open a PHP file in Emacs.
- The PHP CS Fixer will automatically run each time you save the file. You will receive a message confirming that the fixer has been applied.
If you want to run PHP CS Fixer manually on the current buffer without saving, you can invoke the command:
M-x run-php-cs-fixer-on-buffer
The PHP CS Fixer command can be customized by modifying the fixer-command
format string within the run-php-cs-fixer-on-buffer
function.
By default, it uses the following rules:
@PHP80Migration
@PSR12
@Symfony
@PhpCsFixer
Feel free to adjust these rules based on your project's requirements.
This package is released under the AGPL-3.0 License. See the LICENSE file for more details.