12

Github GitHub - nishimaki10/emacs-phpcbf: Format PHP code in Emacs using PHP_Cod...

 3 years ago
source link: https://github.com/nishimaki10/emacs-phpcbf
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

phpcbf.el

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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK