↓ Skip to Content Start of content

php-beautifier.el

Version
0.2.0
Release Date
March 29th, 2017
Source
http://github.com/sodaware/php-beautifier.el/
Download zip   Download tar.gz

php-beautifier.el is a lightweight extension that integrates PHP source code beautification into Emacs using the PHP_Beautifier tool. It also supports running code through phpcbf to fix coding standard issues.

php-beautifier.el in action Using php-beautifier.el to format a buffer

Installation

All Emacs installs are a little different, but the basic outline is this:

PHP_Beautifier Configuration

php-beautifier supplies the following customisation options:

An example configuration with a full path and tab indentation:

(setq php-beautifier-executable-path "/usr/bin/php_beautifier")
(setq php-beautifier-indent-method "tabs")

phpcbf Configuration

The following options must be set for phpcbf to run:

An example configuration which uses the WordPress coding standard:

(setq php-beautifier-phpcbf-path "/usr/bin/phpcbf")
(setq php-beautifier-phpcbf-standard "WordPress")

When using phpcbf the code is still run through php_beautifier first. In some circumstances this may create some odd results but it usually works.

Usage

php-beautifier can either format an entire buffer or a single region. The php_beautifier tool will only format code contained in a <?php block, so formatting a region that doesn’t contain one will not work.

Interactive Commands

Running Tests

To run unit tests you’ll need Cask installed.

The following command will run all tests:

cask exec ert-runner

Licence

Released under the GPLv3. See COPYING for the full licence.