Drupal Live templates for PHPStorm

Djebbz recently draw my attention on IRC. He has put up a GitHub repository with a way to bulk export Live templates from the Drupal code.

Explanation

It's a perl script that parses the Hooks API files (mainly contained within the Examples module and in *.api.php files in contrib modules).

Usage

First, close PHPStorm as it overrides files while closing.
Basic hooks are already available in the user.xml file in the repository, on Mac OSX all you have to do is:
cd ~/Library/Preferences/WebIDE10/templates
curl -O -# https://raw.github.com/DjebbZ/Drupal-PHPStorm-Live-Templates/master/user.xml

Then start PHPStorm and in your code type h_menu<TAB> to insert a hook_menu.
Note that typing hook_menu<TAB> will insert the full hook documentation.

PHPStorm Live template example

More

The script is available in the repository if you wish to add more hooks from other contrib modules. To execute it:
cd /path/to/drupal
find . -name \*.php | xargs grep -l '^function hook_' | xargs /path/to/parse_drupal_api.pl > ~/Library/Preferences/config/templates/user.xml

Enjoy!