Skip to content
This repository has been archived by the owner. It is now read-only.
Format PHP code in Emacs using PHP_CodeSniffer's phpcbf
Emacs Lisp
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
phpcbf.el

README.md

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

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

You can’t perform that action at this time.