Skip to content
PHP QA tools for Vim
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

PHP QA Tools For Vim

This is a plugin for Vim that integrates PHP quality checking tools, to allow you to code to a particular standard and easily spot errors and violations.

It uses PHP linter to check for syntax errors, and integrates with PHP Code Sniffer and PHP Mess Detector to check for coding standard violations.

Quick Guide

The plugin is configured by default to automatically run the QA tools when a PHP file is saved. Therefore, save a file and the linter will run. If there is a syntax error, the offending line will be highlighted. Plus, a quickfix window opens to show the error and it's position in the file.

If there are no syntax errors, PHP Code Sniffer and Mess Detector will run. These require some configuration to fit your needs, which you can read about under the "Configuration" heading. The output of these two commands are combined, and the file is highlighted with the occurences. Again, a quickfix window opens, showing the violations and allowing you to navigate through them.

You can toggle the highlighted lines using the command:


What's the <Leader> key? It's likely to be either \ or ,, but you can set it from the command line or in your .vimrc file using:

let mapleader="@"

or whatever you want it to be.

You can also run each command separately on demand:

  • :Php - check for syntax errors
  • :Phpcs - run code sniffer
  • :Phpmd - run mess detector


Installation is easy-peasy if you're using Vundle. Just add this to your .vimrc file:

Bundle 'joonty/vim-phpqa.git'

and run vim +BundleInstall +qall from a terminal.

If you aren't using vundle, you will have to extract the files in each folder to the correct folder in .vim/.

Note: your vim installation must be compiled with signs and perl for this plugin to work.


The only thing that requires configuration is PHP mess detector. It needs a ruleset XML file (see the mess detector website for more information), which you can specify in your .vimrc file:

let g:phpqa_messdetector_ruleset = "/home/jon/phpmd.xml"

For PHP code sniffer, you can pass arguments to the command line binary (run phpcs --help to see a list). For example:

let g:phpqa_codesniffer_args = "--standard=Zend"

However, don't set the --report= argument, as it won't work!

For all the commands, you can specify the executable:

" PHP executable
let g:phpqa_php_cmd='/path/to/php'
" PHP Code Sniffer binary
let g:phpqa_codesniffer_cmd='/path/to/phpcs'
" PHP Mess Detector binary
let g:phpqa_messdetector_cmd='/path/to/phpmd'


This plugin has reused and modified a lot of the code from the Vim QuickHigh plugin, written by Brian Medley. It required too much modification to be able to use it as a stand-alone plugin, so it has been added to this code. My thanks goes to Brian for the work that's gone into that script.


This plugin is released under the GPL license.

QuickHigh was also released under the GPL license.

Something went wrong with that request. Please try again.