/flycheck-phanclient

Emacs flycheck php checker for quick static analysis. Also see https://github.com/TysonAndre/lsp-phan for Emacs 25.1+

Primary LanguageEmacs LispMIT LicenseMIT

Phan client for Emacs

Description

This package adds support of phan (0.12.0+), the PHP static analyzer, to Emacs (as a flycheck plugin). The main feature is quick analysis of individual php files in a project, with the assistance of a background phan daemon.

This is an early version with very few features.

This is based on https://github.com/stevenremot/emacs-phan

./docs/flycheck_phan_example.png

Installation

Clone this repository to your computer. Then, load it in your Emacs configuration :

(add-to-list 'load-path "/path/to/to/flycheck-phanclient")
(require 'flycheck-phanclient)

Usage

Flycheck checker

First, load the flycheck checker:

(require 'flycheck-phanclient)

Then, start the daemon in the folder to analyze, with the default port of 8486 (see phan/phan#563)

TODO: add a way to configure individual project settings (e.g. .dir-locals.el)

This should be enough to have the flycheck checker run on your project. This will run while the project is being edited, even without saving the file.

Note: The request frequency may still need to be tuned for larger projects.

Configuration

You need to install phan manually, and use a git branch with the phan daemon installed. Ensure that the PHP program phan_client is in your path, or copied to a folder in your $PATH.

Currently, the phan daemon must be started manually on the directory (must have .phan/config.php somewhere in the folder or parent folders). No warning/notice is currently emitted if the daemon is not running.

Type M-x customize-group RET phanclient RET to see the other customization options. More customization options will be added in the future.

Requirements

  • PHP 7.x with the php-ast extension installed (and in the PATH emacs searches for binaries).
  • A PHP project with .phan/config.php set up. See Phan - Getting Started
  • A Phan daemon running in the project folder being opened by Emacs.
  • A Phan 0.12.0+ installation.

Emacs dependencies

Future Work

Create a plugin using the Language Server Protocol for the Emacs client (instead of the Phan-specific daemon mode).