Drupal Development using PhpStorm

The PhpStorm IDE comes with a bundled Drupal Plugin, providing functionality for modules, themes as well as for core Drupal development for Drupal 6, 7 or 8. Combine that with PhpStorm’s excellent PHP, HTML, CSS and JavaScript support, automatic code inspections, debugging and unit testing support and we have a great tool for developing our next Drupal application! In this post, we will see how we can get started with Drupal development in PhpStorm.

From the Welcome screen (or by selecting File | New Project), we can choose to create a new project of the Drupal type. PhpStorm will make sure all include paths are set up and a .module and .info file is created to get started.

When opening an existing Drupal module in the IDE, we will be offered the ability to enable support for Drupal automatically. Enabling it will set up the PhpStorm project we are working in to provide full code completion, Drupal code style and so on.

photo1

While coding, having code completion available is very handy. PhpStorm indexes all code in our project and for any hook invocation, the hook name will be available. We can complete code by pressing Ctrl+Space (Cmd-Space on Mac OS X) and have the IDE create the hook implementation.

photo

From the editor we can also navigate to Hook Invocations, so we can find out where a hook is being invoked, what parameters are passed into it, and so on. While the code is useful, having the API documentation from .api.php files at hand can be useful too. Core, as well as many module authors, provide these files for additional documentation on a hook which goes beyond just seeing the code. The View | Quick Documentation menu (or the F1 key) will bring up Quick Documentation when needed.

photo 2

If quick documentation is not enough, the Drupal API Documentation at https://api.drupal.org/api/drupal can also be invoked from the IDE. Just select the text you are interested in, invoke the context menu in the editor, and then select Search in Drupal API. This will fire up the default browser with the request sent from PhpStorm.

Once that code starts flowing, whether through caffeine or some good music, having a debugger at hand will help analyzing what is happening in code. We can work with Xdebug as well as Zend Debugger to debug our Drupal applications in PhpStorm, even when they are running on a remote server or on a Vagrant box. Speaking of which: the IDE comes with full support for launching Vagrant boxes, downloading plugins and so on.

We can of course also make use of the Acquia Dev Desktop which comes with an Apache web server and a MySQL database and makes it easy to have multiple development Drupal sites running on our machine. From there, we can deploy to the Acquia Cloud and benefit from a Drupal-tuned hosting stack and elastic resources to go from a staging site to full production.

Now, one would say development is more than the IDE, right? That’s true, but PhpStorm gives us a lot of things we can do from within the IDE. Consider Drush, a command line shell and scripting interface for Drupal. We can configure it inside our IDE and get it to run there as well, including autocompletion on all commands. This not only works for Drush but also for Symfony2 (or Drupal 8), Composer and many other tools. We can bring up the command line tool by selecting Tools | Run Command... or pressing Ctrl+Shift+X (Cmd-Shift-X on Mac OS X).

photo 3

Next to command line tools, we can also make use of the Drupal.org issue tracker from within PhpStorm. Once configured (check the Integrating PhpStorm and the Drupal.org Issue Queue blog post by Cameron Eagans for details on configuration), we can start working on a task in the issue tracker, commit to version control and move on to the next item. One smooth development workflow, right in the IDE!

photo 4

Give PhpStorm a try and let us know about your experience. If you are new to PhpStorm, do check our video tutorials page to get you started in no time. We also have a full tutorial on Drupal Development using PhpStorm.

Comments

Posted on by Adib Karim.

The plugin is very effectively working on durpal.PhpStorm is one of the best plug in.
Know more....<a href="http://www .alherabd.com/">alherabd</a>

Posted on by Adib Karim.

It's work well.phpstorm service is better.
More..<a href="http://www .alherabd.com/">alherabd</a>

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Filtered HTML

  • Use [acphone_sales], [acphone_sales_text], [acphone_support], [acphone_international], [acphone_devcloud], [acphone_extra1] and [acphone_extra2] as placeholders for Acquia phone numbers. Add class "acquia-phones-link" to wrapper element to make number a link.
  • To post pieces of code, surround them with <code>...</code> tags. For PHP code, you can use <?php ... ?>, which will also colour it based on syntax.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <h4> <h5> <h2> <img>
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.