Skip to content

Latest commit

 

History

History
129 lines (88 loc) · 6.8 KB

File metadata and controls

129 lines (88 loc) · 6.8 KB

JetBrains PhpStorm Configuration

This document describes the recommended IDE settings, plugins, and integrations for JetBrains PhpStorm to ensure a consistent development experience across the team.

General Settings

Recommended Plugins

To enhance productivity and code quality, navigate to Settings -> Plugins and install the following plugins:

  • .ignore: Advanced support for .gitignore and .dockerignore files.
  • PHP Annotations: Enhanced support for PHP attributes and annotations.
  • Php Inspections (EA Ultimate): A powerful static code analyzer for PHP (Paid plugin) or free plugin Php Inspections (EA Extended).
  • PHP Toolbox: Provides enhanced autocompletion for various libraries.
  • JetBrains AI Assistant: AI-powered coding assistance.
  • Symfony Plugin: Deep integration with Symfony (Contains some paid features) (Homepage).
  • Rainbow Brackets: Simplifies reading complex nested code.
  • String Manipulation: Powerful text manipulation tools.

Symfony Integration

To enable framework-specific autocompletion and features:

  1. Go to Settings -> PHP -> Symfony.
  2. Check Enable plugin for this project.
  3. Set the Web Directory to public.

💡 Code Quality Tools: If you are setting up PhpStorm to automatically run code inspections, please refer to the tools and configurations described in code-quality.md.

CLI Interpreter (Docker Integration)

To ensure PhpStorm correctly analyzes code, runs PHPUnit tests, and executes linters, you must set up a remote CLI interpreter that points to our Docker environment.

To configure this, navigate to Settings -> PHP and follow the official JetBrains guide for Configuring Remote PHP Interpreters.

CLI Interpreter 1 CLI Interpreter 2

Composer

Navigate to Settings -> PHP -> Composer and set the path to your composer.json file. Verify that the rest of the settings match the example below:

Composer Settings

Server Path Mappings

To ensure step debugging and remote execution work correctly, you must map your local files to the Docker container. Navigate to Settings -> PHP -> Servers and configure the absolute paths:

Server Path Mappings

Test Frameworks (PHPUnit)

To run and debug tests directly from the IDE, set up the remote PHPUnit integration in Settings -> PHP -> Test Frameworks:

Test Frameworks Configuration

Next, create a Run/Debug Configuration for PHP Remote Debug matching the parameters below:

Remote Debug Configuration

Debugging (Xdebug)

For detailed instructions on setting up and using Xdebug in this environment, please refer to our dedicated Xdebug Documentation.

Code Style & Shared Settings

Our project repository includes the .idea/ directory, meaning most code style and inspection configurations are available out of the box.

Note: If you prefer to manage your own IDE settings, you can add .idea/ to your local .gitignore and delete the folder from your git repository.

If you are starting fresh or do not have the committed .idea/ folder, you can import our recommended code style manually:

  1. Go to Settings -> Editor -> Code Style -> PHP.
  2. Import the Project scheme (CodeStyle.xml) located in the docs/phpstorm directory.

Code Style Import

Quality Tools Integration

PhpStorm can automatically highlight code violations caught by linters (PHP Code Sniffer, PHPStan, Mess Detector).

Enabling Quality Tools

Go to Settings -> PHP -> Quality Tools and configure the paths to the tools inside the Docker container.

Quality Tools Overview

PHP_CodeSniffer

PHPCS Config 1 PHPCS Config 2

PHP CS Fixer

Ensure you select the proper local path for the ruleset .php-cs-fixer.dist.php.

CS Fixer Config 1 CS Fixer Config 2

PHPStan

PHPStan Config 1 PHPStan Config 2

Mess Detector

Ensure you select the proper local path for the ruleset phpmd_ruleset.xml.

PHPMD Config 1 PHPMD Config 2

Importing the Inspections Profile

If you are not using the committed .idea/ folder, you must import our custom inspections profile:

  • Go to Settings -> Editor -> Inspections and import the Project Default profile (Inspections.xml) from the docs/phpstorm directory.

Inspections Import

External Tools (Manual Execution via IDE)

For convenience, you can add custom right-click context menu actions to run linters on specific files or folders. Go to Settings -> Tools -> External Tools and create the following tools:

Tool 1: ECS (Easy Coding Standard)

  • Arguments: exec-bash cmd="./vendor/bin/ecs --clear-cache check $FilePathRelativeToProjectRoot$"

ECS External Tool

Tool 2: PHPCS (CodeSniffer)

  • Arguments: exec-bash cmd="./vendor/bin/phpcs --version && ./vendor/bin/phpcs --standard=PSR12 --colors -p $FilePathRelativeToProjectRoot$"

PHPCS External Tool

💡 Usage: Right-click any file or folder in the project tree, navigate to External Tools, and select ecs or phpcs.


Running Full Project Inspections: To run a full project analysis utilizing all configured quality tools, use the IDE's main menu: Code -> Inspect Code.

External Documentation & References

For deeper customization and troubleshooting, please refer to the official documentation and plugin pages: