by Angus Mak on April 4, 2013 // Short URL

PhpStorm for Drupal

Setting up PhpStorm for Drupal's Coding Standards

Debugging Drupal modules and themes (or Drupal core itself) can be challenging without a good IDE. After using numerous IDE and text editors, PhpStorm has earned its place as my primary IDE for almost anything Drupal-related. By default, PhpStorm is as Drupal friendly as most other IDEs. However, some of its default syntax and formatting settings conflict with the Drupal Coding Standards. Here are a few tips to make PhpStorm play even better with Drupal.


Although not related to Drupal, the Keymap is the first thing I change. By default, PhpStorm comes with keyboard shortcuts I find very unnatural. Under Preferences, scroll down to select Keymap on the left, and select the keymap that suits your needs. Mac OS X 10.5+ feels the most intuitive to me. You can also further customize the keyboard shortcuts to each of the actions. Keymap

Syntax and Formatting

Next, let's fix the code style. Drupal recommends less than 80 characters per line, and PhpStorm lets us set that as its default.


This gives you a nice solid line in the editor showing where the 80 character limit is. I leave the "Wrap when typing reaches right margin" setting unchecked; otherwise, PhpStorm will automatically insert line breaks when I hit 80 characters. Drupal's coding standards do allow more than 80 characters in some situations, so it's best not to require it.


Next, we'll work on PHP syntax. PhpStorm conveniently comes with a predefined style for Drupal that we can use as a starting point.

Predefined Drupal style

PhpStorm's "Tabs and Indents" settings should all be set to two characters to match Drupal's indentation standards. On its "Spaces" tab, make sure the "After type cast" option is selected.


On the "Wrapping and Braces tab", make sure these settings are set correctly:

  • Keep control statements in one line should be unchecked
  • Place braces in class declaration should be unchecked
  • Place braces in function declaration should be unchecked
  • Always force braces for if() statements should be checked
  • Force braces for while() statements should be checked
  • Else on new line for if() statements should be checked
  • 'While' on new line for do...while() statements should be checked
  • 'Catch' on new line for for try() statements should be checked
  • Chop down Array initializer if long should be checked
  • New line after ( for Array initializer should be checked
  • Place ) on new line for Array initializer should be checked

Wrapping and Braces

Wrapping and Braces

Finally, on the "Other" tab, be sure that "Convert True/False to uppercase" and "Convert Null to Uppercase" are checked as well. Those changes should be all we need to match Drupal's PHP syntax. You might also want to set up syntax for other languages like HTML, JavaScript, CSS and any CSS preprocessors you may use.

PHP CodeSniffer

I like to install the PHP CodeSniffer to give myself extra warnings about some Drupal Coding Standards violations. To set that up for yourself, follow the instructions to install PHP CodeSniffer and the Drupal coding standards definitions. Once you have phpcs ready, set up PhpStorm's Code Sniffer settings to point at /usr/bin/phpcs. Also, make sure PhpStorm is set up to use the PHP Code Sniffer for code inspection in its "Inspections" settings.


Now you should get some nice warnings as reminders for keeping up the coding standards.

Inspector Warnings

Tips and Tricks

If changing the font size is not something you often do, I would also recommend turning off the "Mouse wheel zoom" feature. I noticed a lot of accidental zooming in and out when using Magic Mouse on OSX. Even when the Mouse Wheel zoom is turned off, I can still use Pinch-to-Zoom on the trackpad when I need to. You can also set up your own keyboard shortcut under Keymap in Preferences.



One of the biggest advantages to using an IDE like PhpStorm is integration with a good PHP debugger. If you want to XDebug to examine Drupal's internals, see our article about configuring Xdebug. It should give you everything you need to set up PhpStorm for serious debugging.

Angus Mak

Senior Developer

Want Angus Mak to speak at your event? Contact us with the details and we’ll be in touch soon.


Add Your Comment


Uh, timely

I just grabbed the trial last week. Thanks this is very timely and helpful.

Angus Mak++



EAP++ Although I own a


Although I own a license key, I'm using EAP version regularly. It's quite stable.



Is PHPStorm recommeneded for Drupal?

I have been using other editor for coding Drupal so far. I have heard about PHPStorm for the first time after reading your article here. Is PHPStorm considered as recommended editor for Drupal projects? Although I see few customization to make it more Drupal friendly.



I don't think there is a recommended editor

I wouldn't say PhpStorm is the recommended editor for Drupal, in fact I don't think there is such a thing as a recommended editor. I usually switch between PhpStorm, Vim and Sublime Text depending on the task, but I do use PhpStorm the most out of all the editors. I would at least give it a try and see what you like and not like about it.


Kevin Quillen

PHPStorm is by far the best

PHPStorm is by far the best visual IDE I have encountered in my 10 years of dev. It is more than just a code editor, the plugins for version control, UML, JS, etc really cut down on coding time. The XDebug support is great too.

I would put my money on JetBrains IDE products any day of the week.



Excellent! I've been trying

Excellent! I've been trying to find good IDE for a while now... gonna dive in a give it a try!


Jason Maggiacomo

Looks alright, but I rather use NetBeans

The IDE software looks good, probably one of the good ones out there, but honestly compared to what Netbeans gives me I rather use that. It's free compared to this and can dive into the core Drupal source reading PHPdocs to use it for code completion, so I know what function does what, without having to refer to I can even remotely connect to mySQL server to see what records were added and/or modify the structure. It's great for both module development and theme design. It has tab shortcuts like you have in editors like TextMate. The only issue with Netbeans is that it is resource heavy, but honestly for what it can do with not just PHP development, I am fine with it.



I like NetBeans too

NetBeans and TextMate have been my main editors for a few years before I switched to PhpStorm and Sublime Text. I don't quite remember why I switched to begin with, but I find that the PhpStorm debugger works a lot better for me.


Daniel Nolde

Doesn't PHPStorm come with Drupal support?

Isn't there an a bit more automated way to set up PHPStorm for Drupal? Thought PHPStorm comes with some Drupal coding standard support since even version 4, see and

Some additional good reads for setting up PHPStorm (also older version) for Drupal also:


Donny Nyamweya

Productivity vs passion

I have tried a myriad of editors and I am often enticed by the rebel idea of using something like VIM or other simple editor. However, I must keep in mind that my objective is efficient Web Development, not the side-show of editors. I have been using Coda (1 and 2) for a while and I like the simplicity. I however find them lacking in features and I am pleased with the potential productivity gains of using a full-featured IDE like PHPStorm. Granted there is a learning curve, but then again, once I am over that, I hope to reap the benefits Reply



Thanks for posting this Angus. I feel like I've been searching for a good PHP IDE since Zend Studio merged with Eclipse.



On windows enviroment you

On windows enviroment you should use path <your_xampp_folder>/php/phpcs.bat instead of /usr/bin/phpcs (in PhpStorm settings PHP -> Code Sniffer)


Add Your Comment