Setting It Up

You can either use your existing code style scheme or create another one. In both cases it works the same way: Drupal settings are applied to your currently selected scheme. After choosing Settings|Code Style|PHP, simply click to “Set from…” link at the right top corner and select Predefined Style|Drupal as shown below:

The settings which are not required (explicitly specified) by Drupal coding style are left unchanged.

Drupal-style Formatter in Action

Let’s take a small code fragment, for example:

After reformatting the code will be adjusted according to Drupal coding standards:

If you run Drupal coder-review afterwards, it will likely report few errors/warnings instead of hundreds which you normally would have with an arbitrary code not following Drupal coding standards. All the messages like “Use an indent of 2 spaces”, “Curly braces { should end a line” etc. will be gone.

It’s a nice feature to try in PhpStorm 4.0 EAP if you are coding for Drupal. Let us know what you think about it and submit your findings and improvement suggestions in YouTrack.

Boris, I don’t think this is something we should ask the kind folks of JetBrains for. I’d like to see TYPO3 coding style support, too though. For TypoScript support I rather see the TYPO3 community as the ones who should provide that if PhpStorm can/does provide a suitable API for it… After all it’s a PHP IDE, not a TYPO3 IDE.