You are here: User Guide > Tasks > Working with Plugins > Working with PHP_CodeSniffer

Working with PHP_CodeSniffer

This topic explains how to configure and work with the PHP_CodeSniffer plugin.

Prerequisites

How do I install the PHP_CodeSniffer plugin?

Configuring PHP_CodeSniffer

 

 

Instructions on how to complete a procedure

To configure PHP_CodeSniffer:

  1. From the Menu-bar, select Window | Preferences | PHP Tools | PHP_CodeSniffer.

  1. Configure the PHP_CodeSniffer preferences window as follows:

    • PHP Executable- Select a PHP Executable for running PHP CodeSniffer.
    • PEAR Library- You may choose to use your own PEAR library or the internal library.

Note:

The internal library is always within the include path, missing packages are used from there.

  • Debug- If you wish to print PHP output to the console for the purpose of debugging, select the print PHP output to console checkbox.

  • CodeSniffer Standards- Select one or more included CodeSniffer Standards as Default or add your own. To add a custom standard click New... and provide a Name and a Path for it.

  • Standard Tab Width- Select your Tab width.

  • File Extensions- Specify the file extensions for files you wish to be sniffed.

  • Ignore Directories and Files- To ignore directories and files you can specify patterns. Multiple patters are separated by a comma. (For example: Use "*/lib/*" to exclude all lib folders)

Note:

Slash "/" can always be used as a directory separator.

  • Ignore Sniffs- You can specify sniffs which are to be ignored. As names, use the source attribute from the debug output (|For example: Generic.Files.LineLengthSniff).

For more details on how to work with PHP_CodeSniffer, click here.

Validating Files Manually

You can manually execute PHP_CodeSniffer on a specific project file.

 

 

Instructions on how to complete a procedure

To manually validate a file:

  1. In the PHP Explorer, select the file you wish to validate.
  2. On the Tool-bar, click the Validate with PHP_CodeSniffer icon .
    -OR-
    Right-click, and select PHP Tools | PHP CodeSniffer.
  3. In the Console view, expand the Display Selected Console drop-down menu, and select PHP Tools Output to view generated output.

For more details on how to work with PHP_CodeSniffer, click here.

©1999-2012 Zend Technologies LTD. All rights reserved.