Skip to content

Format PHP code in Emacs using PHP_CodeSniffer's phpcbf

License

Notifications You must be signed in to change notification settings

purcell/emacs-phpcbf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

phpcbf.el melpa badge melpa stable badge

Introduction

Format PHP code in Emacs using PHP_CodeSniffer's phpcbf.

Installation

You can install phpcbf.el from MELPA with package.el (M-x package-install phpcbf).

And you can also install it with el-get.

Features

phpcbf

If called interactively, the current buffer is formatted according to phpcbf-standard. Default standard is "PEAR".

phpcbf-enable-on-save

Add this to init file to run phpcbf on the current buffer when saving:

(add-hook 'php-mode-hook 'phpcbf-enable-on-save)

Sample Configuration

(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)

Customize

phpcbf-executable

Location of phpcbf command (default is called (executable-find "phpcbf")).

phpcbf-standard

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

See Also

PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.

About

Format PHP code in Emacs using PHP_CodeSniffer's phpcbf

Resources

License

Stars

Watchers

Forks

Packages

No packages published