Skip to content
tchule edited this page Jan 6, 2017 · 6 revisions

Welcome to the phpcheckstyle wiki!

Overview

PHPCheckstyle is an open-source tool that helps PHP programmers adhere to certain coding conventions. The tools checks the input PHP source code and reports any deviations from the coding convention.

The tool allows you to configure it to suit your coding standards. The configuration file is a simple to understand xml file explained in the Configuration section.

Requirements

  • PHP 5.0 or newer.
  • Web browser to view the checkstyle report (for html reports)
  • That’s all

Installation

  • Unzip the distribution.
unzip phpcheckstyle.zip

Configuration

The configuration file used by default is config/default.xml.

The user can customize this to suit it to specific coding convention by creating a new configuration file and commenting/uncommenting some tests.

To change the configuration file used, use the --config flag of the command line.

Note : The php.ini used in CLI (Command Line Interface) may be different than the php.ini used by your web server. If the "short_open_tag" param is "Off" in the php.ini, the PHP tokenizer will not correctly return the tokens inside short tags.

Running PHPCheckstyle

  • Change directory to the PHPCheckstyle installation directory.
cd phpcheckstyle
  • Execute the run.php script providing the --src option.
php run.php --src "php source directory/file"