PHPackages                             uzulla/phpstorm-inspect-code-cli-runner - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. uzulla/phpstorm-inspect-code-cli-runner

ActiveLibrary[Testing &amp; Quality](/categories/testing)

uzulla/phpstorm-inspect-code-cli-runner
=======================================

CLI tool that runs PhpStorm's code inspections and outputs structured results for easier refactoring and find bugs.

v1.0.1(1y ago)511MITPHPPHP &gt;=8.3

Since Mar 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/uzulla/phpstorm-inspect-code-cli-runner)[ Packagist](https://packagist.org/packages/uzulla/phpstorm-inspect-code-cli-runner)[ RSS](/packages/uzulla-phpstorm-inspect-code-cli-runner/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (3)Used By (0)

phpstorm-inspect-code-cli-runner
================================

[](#phpstorm-inspect-code-cli-runner)

This package enables you to comfortably use PhpStorm as a CLI tool for static analysis.

Features
--------

[](#features)

- Wrapper for PhpStorm's `inspect.sh` script with additional functionality
- Waits for PhpStorm to finish already running inspections
- Clears PhpStorm's cache before every run to prevent stale cache issues
- Parses XML output generated by PhpStorm and presents it in a readable form
- Supports both text and checkstyle output formats
- Modern PHP 8.3 implementation with Symfony Console integration
- Tested with PHPStorm 2024.3

Installation
------------

[](#installation)

```
composer require shopsys/phpstorm-inspect
```

Usage
-----

[](#usage)

```
vendor/bin/phpstorm-inspect inspect \
  --inspect-sh=/path/to/PhpStorm/bin/inspect.sh \
  --system-path=/path/to/.WebIde*/system \
  --project-path=/path/to/project \
  --profile=/path/to/project/.idea/inspectionProfiles/Project_Default.xml \
  --directory=/path/to/inspect \
  --format=text
```

### Arguments

[](#arguments)

- `--inspect-sh`: Path to `inspect.sh` script
- `--system-path`: Path to `.WebIde*/system` directory
- `--project-path`: Path to project directory (that contains `.idea` directory)
- `--profile`: Path to inspection profile XML file
- `--directory`: Path in which are the inspected sources
- `--format`: Format of output result, accepted values: "text" (default) / "checkstyle"

### Environment Configuration

[](#environment-configuration)

You can configure PhpStorm binary paths using a `.env` file:

1. Copy the `.env.example` file to `.env` in the project root:

    ```
    cp .env.example .env
    ```
2. Edit the `.env` file with your specific paths:

    ```
    PHPSTORM_INSPECT_SH=/path/to/PhpStorm/bin/inspect.sh
    PHPSTORM_SYSTEM_PATH=/path/to/.WebIde*/system

    ```

When environment variables are set, you can omit the corresponding command-line options:

```
vendor/bin/phpstorm-inspect inspect \
  --project-path=/path/to/project \
  --profile=/path/to/project/.idea/inspectionProfiles/Project_Default.xml \
  --directory=/path/to/inspect \
  --format=text
```

Example Usage
-------------

[](#example-usage)

### Creating a Simple Inspection Profile

[](#creating-a-simple-inspection-profile)

If you don't have an existing inspection profile, you can create a simple one:

```

```

Save this to a file named `inspection-profile.xml` in your project directory.

### Running the Inspection

[](#running-the-inspection)

You can run the inspection on your project's source code:

```
php bin/phpstorm-inspect --project-path=$(pwd) --profile=$(pwd)/inspection-profile.xml --directory=$(pwd)/src
```

### Self-Inspection Example

[](#self-inspection-example)

A good way to test the tool is to use it to inspect its own code:

```
# Create a simple inspection profile
cat > inspection-profile.xml
