GithubHelp home page GithubHelp logo

drupal-phpstorm-live-templates's Introduction

PHPStorm Live Templates for Drupal 7

What ? Why ?

Lazy programmers (i.e. every programmer) like to use code snippets. The goal is to write less code and program faster. IDE's (or text editors like VIM) allow the use of such snippets to write for us commonly used functions.

The purpose of these Live Templates is to provide Drupal devs such templates for Drupal hooks. It was generated using a Perl script that basically create PHPStorm Live Templates from *.api.php files in Drupal /includes and /modules directories. The output is a bit raw, so it needs some love and polish.

How to use the script generator

You need Perl in your machine. This script was written under Debian Linux, so it may need some adaptations for others OS's.

Type these commands :

$ cd /path/to/drupal  
$ find . -name \*.php | xargs grep -l '^function hook_' | xargs /path/to/parse_drupal_api.pl > ~/.WebIde10/config/templates/user.xml

How to use the Live Templates

  1. (optional) For security's sake, back up your original user.xml file if it exists.
  2. Copy the user.xml file into ~/.WebIde10/config/templates
  3. Restart PHPStorm.
  4. Type h_HOOKNAME<tab> for short version, hook_HOOKNAME<tab> for annoted version (with core comments)
  5. Profit !

License

Copyright (C) 2011 Jeremie Le Hen [email protected]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Credits

Props to Jeremie Le Hen who wrote the Perl script that generated the templates.
Special thanks to blup for the original idea and work (VIM snippets for Drupal)

drupal-phpstorm-live-templates's People

Contributors

djebbz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

drupal-phpstorm-live-templates's Issues

Consider different filename and template group

PHPStorm supports multiple configuration files and groups for live templates. Changes made using the IDE interface go to file user.xml and template group "user".

To separate your (great!) stuff from user settings, I'd suggest using a different filename and group in the script, e.g. "d7_hooks". Just change the filename to "d7_hooks.xml" and the template group to "d7_hooks", using templateSet group="d7_hooks".

This way you avoid conflicts like overwriting existing configurations or merging user settings and script output. Of course you could use any name here, maybe "DjebbZ"...

include module name in tab completion

Hey - Amazing tool, thanks! Just started using PhpStorm and desperately missed my TextMate Drupal bundle. Have you looked into whether it's possible to include the module name in the resulting function? I'm guessing no, but figured I'd ask.

Path for phpstrom 4

Great work on this. FYI the path for phpstrom 4 is ~/Library/Preferences/WebIde40

You might also put in a suggestion to add an alias to the .bashrc/.zshrc file to make it easier to update.

Mine is

alias phpstrom-update= 'find . -name \*.php | xargs grep -l "^function hook_" | xargs /Users/indytechcook/dotfiles/phpstrom_live_templates/parse_drupal_api.pl > ~/Library/Preferences/WebIde40'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.