IntelliJ IDEA 2017.1 Help

Preparing for Drupal Development in IntelliJ IDEA

This feature is supported in the Ultimate edition only.

In this section:

Before you start

  1. Download and install Drupal.
  2. Install and enable the Drupal plugin. The plugin is not bundled with IntelliJ IDEA, but it can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins. The plugin is not bundled with IntelliJ IDEA, but it can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.

Creating a IntelliJ IDEA project with a Drupal module

You can create a IntelliJ IDEA project that will be set up and configured in accordance with the Drupal requirements. This is done by creating a project by a Drupal Module template.

  1. Choose File | New | Project on the main menu or click the Create New Project button on the Welcome screen. The Project Category and Options dialog opens.
  2. In the left-hand pane, choose PHP from the list, then choose Drupal Module in the right-hand pane, and then click Next.
  3. On the second page of the wizard, specify the project name and the folder where it will be created and provide the following Drupal-specific information:
    1. Specify the root folder of the Drupal installation in the Drupal installation path. Type the path manually or click the Browse button /help/img/idea/2017.1/browseButton.png and select the relevant folder in the dialog box that opens.
    2. Select the Set up PHP | Include paths check box to have Drupal include paths automatically configured for the project. The following paths will be added to the Include Paths list on the PHP page of the Settings dialog box:
      1. <drupal installation root>/includes
      2. <drupal installation root>/modules
      3. <drupal installation root>/sites/all/modules

      The include paths are added to the list after you leave the dialog box.

    3. From the Version drop-down list, choose the version of Drupal to use, the supported versions are 6, 7, and 8 .

You can update integration settings at any time later in the File | Settings for Windows and Linux or IntelliJ IDEA | Preferences for macOS.

IntelliJ IDEA generates a project stub in accordance with the selected Drupal version. For Drupal 8, a module_name.info.yml file is generated where information about the module is provided.

Importing a Drupal project

Besides creating a project anew according to the Drupal Module template, you can open an existing Drupal project in IntelliJ IDEA. IntelliJ IDEA recognizes the Drupal-specific structure and suggests activating the Drupal support in the project.

  1. Open the folder with the required Drupal project by choosing File | Open Directory.
  2. As soon as IntelliJ IDEA detects the Drupal-specific structure in the project, the following message is displayed in a pop-up window:
    /help/img/idea/2017.1/drupalStructureDetected.png
    Click the Enable link.
  3. In the Drupal Module dialog box that opens, select the Enable Drupal integration check box and proceed as when creating a project with a Drupal module:
    1. Specify the root folder of the Drupal installation in the Drupal installation path.
    2. Select the Set up PHP | Include paths check box to have Drupal include paths automatically configured for the project.
    3. From the Version drop-down list, choose the version of Drupal to use, the supported versions are 6, 7, and 8 .

You can update integration settings at any time later in the File | Settings for Windows and Linux or IntelliJ IDEA | Preferences for macOS.

Configuring the Drupal-specific development environment

Whether you enable the Drupal support in an existing IntelliJ IDEA project or create a new project with a Drupal module, IntelliJ IDEA checks if the development environment is configured properly for Drupal development.

Any detected inconsistency is reported in the Event Log tool window and as a pop-up. For each discrepancy IntelliJ IDEA suggests a fix. To apply a suggestion, click the link next to the reported event.

/help/img/idea/2017.1/drupalEventLog.png

Configuring file associations

To enable code highlighting, you need to set some additional file type associations to make IntelliJ IDEA recognize and treat them as php files. Do one of the following:

  • In the Event Log tool window, click the Fix link next to the Drupal support: <*.file extension> files are not associated with PHP file type message.
  • Use the File Types page of the Settings dialog box:
    1. Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing File | Settings for Windows and Linux or IntelliJ IDEA | Preferences for macOS, and click File Types under Editor.
    2. In the Registered Patterns area, add the patterns that defined Drupal files to be recognized as php files. To do that, click the Add button /help/img/idea/2017.1/new.png and type the pattern in the Add Wildcard dialog box that opens.

Changing the Drupal settings

No matter whether you enable the Drupal support in an existing IntelliJ IDEA project or create a new Drupal module, you can update the Drupal settings at any time on the Drupal page of the Settings / Preferences Dialog.

  1. Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing File | Settings for Windows and Linux or IntelliJ IDEA | Preferences for macOS, and click Drupal under Languages & Frameworks.
  2. Click Drupal and make the necessary changes on the Drupal page that opens:
    • To turn off the Drupal integration, clear the Enable Drupal integration check box. Note that this automatically excludes the folders specified as include paths.
    • Change the Drupal installation directory and the version of Drupal to use.
  3. To change the include paths, click PHP and make the required changes in the Include Paths area of the PHP page that opens. Note that is the Drupal integration for is disabled, the paths are automatically excluded.
  4. To change the code style settings, click Code Style, and then click PHP. On the Code Style: PHP page that opens, update the settings as necessary.

See Also

Procedures:

Last modified: 18 July 2017