Custom PHP Class templates

Hello Community,

is there a way to create a custom class file template (the "Kind" in the "New PHP class" dialog) in PHPStorm? I wan't to create templates for some Symfony2-specific types but want to use the "New PHP Class" functionallity (for Namespace suggestions a.s.o.) instead of create a file template. I'd really appreciate some help :)

Thanks
Christian

3 comments
Comment actions Permalink

Hi there,

Only by coding your own plugin in Java.

And even then -- I'm not sure if it can be added into that dialog (as it is PHP-specific and PHP plugin is closed-source -- I do not know how it's actually coded there).

Plus: your custom class does not really fit the purpose of that screen (as it is implemented now): it lets you choose between Class, Interface or Trait -- I do not see how "My Special Symfony Class" can fit into this. Via separate additional field (where you can choose PHP Class template) -- sure, but it does not have one....

0
Comment actions Permalink

Hi Andriy,

thanks for your answer. I was also thinking about to fork the Symfony2 Plugin and add the commonly used templates but I want to ask before if it was possible with the already existing tools of PHPStorm.

Of course jetbrains doesn't provide such specific templates since they are custom-specific but it'd be great if it was possible. :) They provide the basic templates like class, interface and trait but now I want to customize it to my fits which are in this case symfony-specific. At the moment I've created a lot of file templates and it works as expected but the facilitation of automatic namespace generation a.s.o. would make it so much easier :)

Thanks and regards
Christian

0
Comment actions Permalink

Sure -- haveing separate field where I can choose actual template would be good to have.

As an (possibly bad) alternative I may suggest to use base PHP Class template (so that you have namespace etc generated automatically) ... and then (once file created and opened in editor) to use custom Live Template to add/replace specific code.

0

Please sign in to leave a comment.