You can use PhpStorm as an IDE for Drupal development including modules, themes, and core. The supported versions are 6, 7, and 8. PhpStorm provides integration between the Symfony2 and Drupal 8 while developing Drupal modules and core. Download Drupal from the Drupal Official website and install it as described in the Drupal installation instructions. You can create a PhpStorm project by a Drupal Module template, this project will be set up and configured in accordance with the Drupal requirements. PhpStorm generates and configured a project stub in accordance with the
selected Drupal version. For Drupal 8, a module_name.info.yml file is generated. Open the New Project dialog Choose or click Create New Project on the PhpStorm Welcome screen. Choose the project type and location In the left-hand pane, select Drupal Module. In the
Location field on the right-hand pane, specify the folder where the project will be created. Choose Drupal installation to use Specify the root folder of the Drupal installation and choose the version of Drupal to use, the supported versions are 6, 7, and 8. Later you can change the Drupal installation and re-configure the include paths on the
Frameworks page as described in Changing the Drupal settings Configure Include paths Select the checkbox to have Drupal include paths automatically configured for the project. After you leave the dialog,
the following paths will be added to the Include Paths list on the PHP page: <drupal installation root>/includes, <drupal installation root>/modules, and <drupal installation root>/sites/all/modules Option 2: Import an existing Drupal moduleWhen you open an existing Drupal module, PhpStorm recognizes the Drupal-specific structure and suggests activating the Drupal support.
Whether you enable the Drupal support in an existing PhpStorm project or create a new project with a Drupal module, PhpStorm 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 popup. For each discrepancy PhpStorm suggests a fix. To apply a suggestion, click the link next to the reported event. Associating Drupal-specific files with the PHP file typePhpStorm recognizes and treats files as php files and provides code highlighting based on file type associations. Option 1: Use the Event log
Option 2: Use the File Types page
Changing the Drupal settingsOption 1: Enable or disable Drupal integration
Option 2: Update the include paths
Using Drupal hooks in PhpStormPhpStorm provides full native support of Drupal hooks in .module files.
Setting up Drupal code style in a PhpStorm projectPhpStorm automatically offers to apply the pre-configured Drupal Coding Standards (code style) if a project is recognized as a Drupal Module, or if the Drupal integration is enabled in an existing project, or when you create a new project with a Drupal Module. However, you can at any time change or customize this setting on the Code Style: PHP page of the Settings dialog. Use the pre-configured Drupal code style in a project
You can also set the predefined code style on the Code Style: PHP page. In the Settings/Preferences dialog (Ctrl+Alt+S), navigate to . Then, click Set from and choose Predefined | Drupal. If applicable, customize the code style using the controls on the page. Checking code against the Drupal coding standardsWith PhpStorm, you can use the PHP_CodeSniffer tool, which detects coding standard issues, in combination with Coder, which provides a set of Drupal-specific standards to PHP_CodeSniffer. This will ensure that your code is clean, consistent, and free of some common errors. To get started, install PHP_CodeSniffer using any technique described in Install and configure PHP_CodeSniffer. Probably the easiest way is to install it with Composer. Install PHP_CodeSniffer
Next, install Coder, which will provide Drupal-specific standards to PHP_CodeSniffer. Install Coder
The Coder package will be installed, and the corresponding Drupal standard will be selected for the PHP_CodeSniffer validation inspection automatically. If necessary, you can further customize the inspection on the page of the Settings/Preferences dialog (Ctrl+Alt+S). See Configure PHP_CodeSniffer as a PhpStorm inspection for details. Viewing the Drupal API documentation from PhpStormIn the PhpStorm editor, select the symbol you are interested in and choose Search in Drupal API from the context menu. The Drupal API Documentation opens. Using the Drush command line tool from PhpStormPhpStorm integrates with the Drush command line shell and scripting interface version 5.8 and later. Before you begin, download and install Drush as described at https://github.com/drush-ops/drush. Configure Drush automatically
Configure Drush manually
Run Drush commands
Terminate a command
Debug Drush commandsDrupal commands are defined in controller classes that extend
Using Drupal 8 with Symfony2PhpStorm provides close integration between Drupal, version 8, and Symfony2. Through this integration, Symfony2 components are connected with Drupal infrastructure. To take advantage of this integration:
What coding assistance for Drupal 8 - Symfony2 integration is available?
Last modified: 01 August 2022 |