Is there a way to define folder templates?

I'm using PhpStorm for Drupal development and it would be great if I could define a template that would setup the appropriate folder and files for a Drupal module.  The desired end result would be the following:

  • Right-click on a folder and select New -> Drupal Module
  • Enter the name of the Drupal module (e.g. "mymodule")
  • PhpStorm would create the following:
    • Folder named "mymodule"
    • PHP file named "mymodule.module"
    • Module info file named "mymodule.info"


Is there a way to do this with PhpStorm already or should I file a feature request?


Thanks,

Shawn.

6 comments

Hi Shawn,

There is no such functionality available in PhpStorm ... and I do not think it's going to be implemented any time soon (as this is Drupal-specific feature, I guess).

You can see what is currently planned for future versions here: http://confluence.jetbrains.net/pages/viewpage.action?pageId=15801728

Existing ticket for Drupal support: http://youtrack.jetbrains.net/issue/WI-6404?projectKey=WI

0

Thanks Andriy,

I think this may be similar to the "Project Template" feature that is being investigated.  I don't consider this to be a Drupal specific feature, but a more generic feature that allows you to define and generate an arbitrary set of files and folders.

0

I know this post is ancient, but this would be super useful for Polymer.  Does anyone know if there is any news on this feature in the last 3 years?

0

For now I have written a batch file that resides in my /templates/ folder.  

@echo off
set seed=seed-element
set target=%1
@echo Creating new element named "%target%"
echo Creating Folder...
md %target%
echo copying seed files from %seed%...
copy %seed%\%seed%.html %target%\%target%.html >nul
copy %seed%\%seed%.less %target%\%target%.less >nul
copy %seed%\demo.html %target%\demo.html >nul
copy %seed%\index.html %target%\index.html >nul
copy %seed%\readme.md %target%\readme.md >nul
copy %seed%\bower.json %target%\bower.json >nul
copy %seed%\tests %target%\tests >nul
echo Done!


So now I can just open the terminal and type "create my-new-template" and it does the rest.

0

I have updated my batch file.  It now scans files for a ${NAME} variable and replaces each instance with the specified name.  Currently, the bat file is hard-coded to match a Polymer file structure, but it is very easy to modify.

Here it is on Github if anyone is interested: https://github.com/ScottBeeson/polyclone

0

Please sign in to leave a comment.