---
title: "Developing Drupal projects using PhpStorm"
date: "2022-03-15T03:46:17+00:00"
summary:
image:
type: "article"
url: "/acquia-cloud-platform/help/93446-developing-drupal-projects-using-phpstorm"
id: "6da1d4aa-0566-40d0-81fa-7cd8f19ca84d"
---

Table of contents will be added

Note: These instructions were written for PHPStorm 2018.1, and may need to be adjusted for other versions.

Setting up inspections
----------------------

PHPStorm includes many built-in inspections for PHP. You can enable or disable each inspection individually in the user interface. Most of the inspections make sense in the context of Drupal projects, but not all.

To ensure consistent validation across all environments on your project, it s better to disable PHPStorm's built-in inspections and instead delegate code sniffing to Coder and PHPCodeSniffer. Use the `phpcs.xml` rule sets that you distribute with your project (and that BLT provides by default).

To do this, complete the following steps:

1.  Open PHPStorm, and in its main menu, go to **PHPStorm > Preferences**.
2.  Go to **Languages & Frameworks > PHP > Code Sniffer**.
3.  Open the window next to **Configuration**, and then select the PHPCS binary in your project that is located at `vendor/bin/phpcs`.
4.  Go to **Editor > Inspections**.
5.  Clear the **PHP** check box to disable all PHP inspections.
6.  Select the **Undefined > Undefined variable analysis** check box (as Coder 2 doesn't support this).
7.  Select the **Quality tools > PHP Code Sniffer validation** check box.
8.  In **PHP CodeSniffer configuration**, change the coding standard to **custom**, and then select the `phpcs.xml` file in the root of your project.

Setting up Xdebug
-----------------

For a tutorial about how to set up PHPStorm, Xdebug, and DrupalVM to work together, see [https://danepowell.com/blog/xdebug-phpstorm-drupalvm](https://danepowell.com/blog/xdebug-phpstorm-drupalvm).

Additionally, to support the following PHPUnit testing and debugging instructions, you can enable Xdebug for the CLI SAPI:

    php_xdebug_cli_disable: no

Setting up PHPUnit testing and debugging
----------------------------------------

To use PHPStorm, Xdebug, and DrupalVM together in a Drupal testing workflow, you will need to complete some additional configuration:

1.  Configure the remote CLI interpreter.
    1.  Go to **PHPStorm settings / preferences**.
    2.  Go to **Languages & Frameworks > PHP**.
    3.  Open the window next to **CLI Interpreter**.
    4.  Click the plus ( **+** ) to add a new interpreter, and then select **From Docker, Vagrant, VM, Remote.**.
    5.  In the **Configure Remote PHP Interpreter** dialog box, click **Vagrant**, and then set the **Vagrant Instance Folder** to the root of your project.
2.  Configure the debug settings.
    1.  Go to **PHPStorm settings / preferences**.
    2.  Go to **Languages & Frameworks > PHP > Debug**.
    3.  Select the **Force break at first line when no path mapping is specified** check box under **Xdebug**.
    4.  Select the **Force break at first line when a script is outside the project** check box under **Xdebug**.
3.  Configure your server settings.
    1.  Go to **PHPStorm settings / preferences**.
    2.  Go to **Languages & Frameworks > PHP > Servers**.
    3.  Click the plus ( **+** ) to add a new sever configuration.
    4.  Enter the host name of your project in both the **Name** and **Host** fields (for example `local.my-project.com`).
4.  Configure the test frameworks.
    1.  Go to **PHPStorm settings / preferences**.
    2.  Open **Languages & Frameworks > PHP > Test Frameworks**.
    3.  Click the plus ( **+** ) to add a new test framework configuration, and then click **PHPUnit by Remote Interpreter**.
    4.  Select the remote CLI interpreter you configured in a previous step of this process.
    5.  In **PHP Unit library**, click **Use Composer autoloader**.
    6.  Open the window next to **Path to script**, and then select the autoloader file in your project at `vendor/bin/phpcs`.
    7.  In **Test Runner**, click **Default configuration file**, and then select the configuration file in your project, as `docroot/core/phpunit.xml`.
5.  Configure your test configurations.
    1.  From the main menu, go to **Run > Edit Configurations**.
    2.  Click the plus ( **+** ) to add a new configuration, and then click **PHPUnit**.
    3.  In the **Name** field, enter the hostname of your project (for example, `local.my-project.com`).
    4.  In **Test Runner**, click **Defined in the configuration file**.
    5.  Optionally, add any additional configuration or commands you want to use for testing.
6.  Optionally, install and use [https://github.com/mglaman/intellij-drupal-run-tests](https://github.com/mglaman/intellij-drupal-run-tests) for an additional set of test configurations specifically for Drupal.