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!
Qodana Clone Finder: Early Access Program
In December 2020, we announced the EAP for Qodana, which is rapidly evolving into a comprehensive platform that allows companies to perform multi-level evaluations of the quality of code they own, contract, or purchase. Qodana helps you detect bugs without relying on an IDE, either on a local machi…
PhpStorm 2020.2 EAP #3
The Early Access Program for PhpStorm 2020.2 is in full swing and today we’ve got the third build of the 2020.2 EAP for you. In this blog post, you can read about improvements for Git installed in WSL2 and Search Everywhere. Download PhpStorm 2020.2 EAP (more…)…
PhpStorm 2019.3.3 Preview
We’ve just rolled out a preview for the third minor update for PhpStorm 2019.3. Please give the PhpStorm 2019.3.3 Preview build 193.6494.5 a try and share your feedback with us. (more…)…
How to Upgrade to PHP 7.4 with PhpStorm
Check out our fresh video with a few nice tips and tricks on how to update your codebase to PHP 7.4. It combines materials from the PhpStorm 2019.2 and PhpStorm 2019.3 releases, with a few cool bonuses to boot. Nikita drew our attention to the fact that setters are slower than assigning prop…