Hello guys,
I got great news for you: I’ve created 2 new NetBeans plugins for increasing the speed of development with Symfony2.
First let’s talk about
Udevi Symfony2 Code Templates
Plugin details page: http://plugins.netbeans.org/plugin/42128/udevi-symfony2-code-templates
Plugin code: https://github.com/Monomachus/Symfony2CodeTemplates
So this is something I was thinking about when I started developing a real world applications - code templates, snippets of code that will help me create Symfony2 applications in NetBeans faster and more effective, I searched in Google, and I found this one (http://www.symfony-zone.com/wordpress/netbeans/).
Timo Haberkern – is the guy who created a set of code templates and exported them, he also has the CheatSheet that will help you figure out what each template does. Thank you very much Timo ! Great job !
I took those templates, modified them a little bit, removed some, added some new templates and created a new plugin. I was very happy but when I started testing it I found out that the PHP code templates in NetBeans 7.1 were not working. It was a bug in NetBeans . Here’s the original issue: http://netbeans.org/bugzilla/show_bug.cgi?id=206413
So the issue was fixed in 7.1.1 and you can finally use my plugin , but the Twig completion is still broken, I will create a new issue for the guys in NetBeans to fix it. So it doesn’t work for Twig, but still works for everything else.
I uploaded the plugin to NetBeans Plugin Portal, the verification is pending but I hope it will soon pass. I suggest you use the plugin and say what do you think about it. If there are any bugs please report them on github. Please use NetBeans 7.1.1 . Soon I’ll make a new post with the complete list of code templates.
Udevi Symfony2 File Templates
Plugin details page: http://plugins.netbeans.org/plugin/42127/udevi-symfony2-file-templates
Plugin code: https://github.com/Monomachus/Symfony2FileTemplates
UPDATE: you can also use the Symfony2 interactive generators. More info here (http://qpleple.com/code-faster-symfony2s-interactive-generators/)
This one was a little bit harder to do, but the main goal was to avoid writing over and over pluming code that actually could be written or rewritten using file templates and/or code generation… I like this feature in the IDEs because it saves you a lot of time and the task of writing over and over even 20 keystrokes is not fun.
So I created 3 file templates by default
- Symfony2 Entity Template: This template includes generating an entity with guessed namespace: this namespace is guessed by the absolute name of the new file. The name of the table in DB is guessed upon the name of the entity with underscores between words if there are multiple words, the wizard also has the optional table name and the checkbox to create the annotation for repository or not.
- Symfony2 Controller Template: This is just a template of a new controller with guessed namespace and some useful default uses (Symfony2 Controller and Response) and a new default indexAction.
- Php Class with Namespace: This one is the most wanted for me but still not that good because it is based on supposition that all the Php classes you would need to create with namespace are inside of the ‘src’ folder.
Some templates I would also like to create but don’t know how yet
- Symfony2 Form Type: It would receive as a parameter the entity and than created in buildForm method each method with description. If field is an id automatically suppose it is hidden. I don’t know how to do it now because of the fact that I don’t know how to get metadata of a PHP entity in Java, hope Oracle guys will help me in that.
- A ViewModel for an Entity: Now when I don’t need to show everything I have in the entity to the screen I use view models. I would also need a generator that take an entity and creates a ViewModel with all the fields of the entity.
Thought about creating the template for Repository but the command line function lower helps you generate your Repository class.
app/console doctrine:generate:entities BundleNamespace
The first time you run the New file-> template from my plugin it runs slow (up to 6-8 seconds) because NetBeans need to index all the files in the plugin, next times it is faster, like 3 seconds. Still a bad performance, perhaps someone from Oracle could help me with that.
Please share what other file templates you would like to seen in this plugin, how well did the plugin go, do you have any problems, questions, concerns, ideas related to it? If any bugs found please declare them in github. Thanks a lot.
P.S. Later on will create a post about how to create a new file wizard module plugin, hope it will help someone. Are you interested in something like this ?
P.S.S. Dear guys from PHP NetBeans team, if you are reading this please make PHP Project a Public API that I could use in my plugin. There is a Java Project API in NetBeans, but nothing regards PHP, may be it is the time to change it .
Ok guys, next and hopefully the last question do you think I should unify these 2 plugins in 1 ?
Thanks a lot and happy coding !