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.
    The PHP CodeSniffer dialog is displayed.

  1. Select a PHP executable from the drop-down menu for running PHP_CodeSniffer.
  2. If you wish to print PHP output to the console for the purpose of debugging, select the print PHP output to console checkbox.
  3. Click here to download a PEAR library.
  4. In the PHP CodeSniffer preferences dialog, click PEAR Libraries.
    The PEAR dialog is displayed.
  5. Click New.
    The New Library Path dialog is displayed.

  1. Name a name for the new PEAR library, enter the path to the PEAR library you downloaded, and click OK.
  2. Back in the PEAR dialog, click Apply.
  3. In the PHP CodeSniffer dialog, click the PEAR Library drop-down menu, and select the newly added library.
    The list of built-in standards are displayed in the CodeSniffer Standards table.
  4. Select a standard to use from the CodeSniffer Standards table, or click New to create your own standard.
  5. Continue configuring the PHP_CodeSniffer preferences window as follows:

    • 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).
    • 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).
  • Note:

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

  • 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-2013 Zend Technologies LTD. All rights reserved.