Coding Standard Class Methods (Previous) (Next) FAQ

View this page in Last updated: Sun, 28 Sep 2008
English | French | German | Japanese | Plain HTML

Using the Subversion pre-commit Hook

Using the Subversion pre-commit Hook -- How to configure the Subversion pre-commit hook

What Does the Subversion pre-commit Hook Do?

A pre-commit hook is a feature available in the Subversion version control system that allows code to be validated before it is committed to the repository. The PHP_CodeSniffer pre-commit hook allows you to check code for coding standard errors and stop the commit process if errors are found. This ensures developers are not able to commit code that violates your coding standard. Instead, they are presented with the list of errors they need to correct before committing.

Configuring the pre-commit Hook

Edit /path/to/PHP_CodeSniffer/scripts/phpcs-svn-pre-commit and replace @php_bin@ in the first line with the path to the PHP CLI. For example, #!@php_bin@ becomes #!/usr/bin/php.

Now ensure the path to svnlook is correct by modifying the following line, if required:

Now add the following line to your pre-commit file in the Subversion hooks directory:

You can also use all the standard phpcs command line options to do things like set the standard to use, the tab width and the error report format:

Coding Standard Class Methods (Previous) (Next) FAQ

Download Documentation Last updated: Sun, 28 Sep 2008
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.