PhpStorm 2018.1 Help

Launching Code Inspection from Command Line

In addition to running code inspections from the main menu or from the context menus of the Project Tool Window, you can also launch the inspector from the command line, without actually running PhpStorm.

This way you can perform regular code inspections as a part of your development process, which is especially important for large projects. Inspection results are stored in the XML format, and you can download and view these results at any time.

To launch a code inspection from the command line

  • In the command line, run the inspect command the using the following syntax:
    inspect project-path inspection-path output-path [-vX] [-d subdirectory-path]

The command options are as follows:

OptionDescription
inspect

The full path to the inspect.bat ( inspect.sh on macOS and Linux) script located in the <IDE_HOME>/bin directory.

project-path The full path to the directory that contains the project to be inspected.
inspection-path The full path to the inspection profile, against which the project is to be inspected. By default, inspection profiles are stored under the following directory:
  • On Windows: %HOMEPATH%\.PhpStorm2018.1\config\inspection
  • On macOS: ~/Library/Preferences/PhpStorm2018.1/inspection
  • On Linux: ~/.PhpStorm2018.1/config/inspection
output-path The full path to an existing directory where the inspection report will be stored.
-vX (optional) The verbosity level of the output, where X is 0 for quiet, 1 – for noisy, and 2 – for extra noisy.
-d subdirectory-path (optional) The full path to the subdirectory to be inspected.

Examples

Syntax
<IDE_HOME>\bin\inspect.bat project-path inspection-path output-path -v2 -d subdirectory-path
Example
<IDE_HOME>\bin\inspect.bat E:\MyProject E:\MyProject\.idea\inspectionProfiles\Project_Default.xml E:\MyProject\inspection-results-dir -v2 -d E:\MyProject\subdirectory
Syntax
PhpStorm.app/Contents/bin/inspect.sh project-path inspection-path output-path -v2 -d subdirectory-path
Example
PhpStorm.app/Contents/bin/inspect.sh ~/MyProject ~/MyProject/.idea/inspectionProfiles/Project_Default.xml ~/MyProject/inspection-results-dir -v2 -d ~/MyProject/subdirectory
Syntax
<IDE_HOME>/bin/inspect.sh project-path inspection-path output-path -v2 -d subdirectory-path
Example
<IDE_HOME>/bin/inspect.sh ~/MyProject ~/MyProject/.idea/inspectionProfiles/Project_Default.xml ~/MyProject/inspection-results-dir -v2 -d ~/MyProject/subdirectory

Viewing the results of an offline inspection

Having performed an offline inspection and exported the inspection results to a directory in the XML format, you can always download and view these results.

  1. Open the project the inspection was performed against.
  2. On the main menu, choose Code | View Offline Inspection Results.
  3. In the Select Path dialog box that opens, navigate to the directory that contains inspection results in XML format.
  4. Click OK. Inspection results display in the Offline View tab in the Inspection Results Tool Window.
Last modified: 27 July 2018

See Also