PhpStorm’s Symfony2-specific features for Drupal 8
Drupal v8 and later is based on a number of Symfony2 framework components. There is a Drupal plugin built into PhpStorm with Drupal 8 general support (hooks, drush, etc.), but PhpStorm has excellent support for Symfony2 framework as well through its core features and the Symfony2 Plugin (an Open Source plugin maintained by Daniel Espendiller).
To take advantages of close integration between Drupal and Symfony2 while developing Drupal modules and core, Daniel maintains an additional Drupal Symfony2 bridge plugin, which connects Symfony2 components to Drupal infrastructure in terms of IDE understanding. There is also the PHP Annotations plugin to take advantage of advanced annotations support.
Have a look at the full version of this tutorial on Symfony2-specific PhpStorm’s features for Drupal 8.
First of all, you need to install the plugin in PhpStorm. Open Settings (Preferences) | Plugins, and click Browse repositories…
Search for Symfony2 and install Drupal Symfony2 Bridge plugin with a context menu action. It’s dependent on the main Symfony2 Plugin, which will be installed automatically. If you would also like to get advanced annotations support, install the PHP Annotations plugin as well.
As soon as Symfony2 Plugin with Drupal Symfony2 Bridge plugin are installed, enable Symfony2 Plugin in your project if it’s not enabled yet: Select Settings (Preferences) | Symfony2 Plugin | Enable Plugin for this Project. Then restart the IDE.
Drupal-specific parameters completion in YAML files
Information about modules is now provided inside module_name.info.yml files, and PhpStorm with Symfony2 plugin provide completion for major Drupal-specific parameters in these files:
Completion for t() function strings
Strings suitable for use inside Drupal’s t() function are indexed across your project and offered for completion:
Completion for routing (URL generation) and navigation to routing YAML files
Relevant YAML key values are completed in url() and other Drupal API functions to make it easier to search for the right value:
You can also navigate to the YAML file with Ctrl+Click (CMD+Click on Mac OS X) or Go To Declaration action (Ctrl+B / CMD+B):
Full service container support
There are a lot of handy features for service containers described in YAML files, including completion, navigation with Ctrl+Click / CMD+Click (Go To Declaration action), and more.
Twig template engine support
Symfony’s Twig is now the default template engine for Drupal 8, and PhpStorm with Symfony2 plugins comes with lots of features, such as completion, navigation, Drupal function recognition, and many more.
…and many more features from Symfony2 Plugin and PHP Annotations Plugin
There are a lot of features available in the main Symfony2 Plugin, and most of them are relevant to Symfony-specific part of your Drupal 8 installation. Find more information about the Symfony2 Plugin.
Please report issues to the author’s GitHub issue tracker.
Develop with pleasure!
-JetBrains PhpStorm Team
Subscribe to Blog updates
Thanks, we've got you!