Tuesday, September 18, 2012

X-Share – cool tutorial for learning Symfony2 Framework

Hello,

At the moment of writing this blog post I’m working in Pentalog, which is a computer and technology services company, focusing on low cost offshore/nearshore IT engineering and software development.

Few days ago I found out, that as a result of our summer internship program some of the developers from our company created a great tutorial called X-Share. Following this tutorial you’ll create a website, that permits sharing of some objects between the members of a group. As an example it could be sharing books, sharing of the discount cards, sports equipment, etc. This tutorial is open sourced and is on SourceForge.

I hope you guys will find it useful, because one of you right now could be searching for a practical example of a  Symfony2 working application. And a little disclaimer: although I’m very proud of what my colleagues have done and achieved, I wasn’t involved in any way in creation and developing of this tutorial, so all the credits goes to them.

P.S. It is great to see how open source community evolves, and I hope X-Share become your first place to show to your new junior PHP developer for learning Symfony2 basics.

Friday, August 3, 2012

Unified Udevi Symfony2 Plugin for NetBeans 7.2

Hello,

I’ve recently created the unified Udevi Symfony2 Plugin that contains both File Templates plugin as well as Code Templates plugin. This plugin is made for new version of NetBeans - 7.2. It passed the validation today so you can install it directly from NetBeans. Go to Tools –> Plugins –> Available plugins. You might need to update plugins info, so it will contain the latest list of validated plugins.

plugin_udevi_symfony2

The content of the plugin remained the same, just uniting 2 templates content. The current statistic is

chart_1 (1)

In the previous table I counted number of days that this extension is published in the NetBeans Plugins Center until today. So 2.5 downloads per day isn’t so bad I would say. Probably Symfony2 and NetBeans are a good combination and a lot of people know it. But 5.5 per day is definitely better. I guess now when it is validated in Plugins Center it will sustain current number of downloads per day

chart_1

I would like to give a shout to first and I hope not the last person making 5 pull requests in total for those 2 plugins:

   Smeagol07     -       Thank you very much I hope that with the input of the community I will improve the quality of the product into something much bigger, than it is today.

 

I would also like to thank NetBeans team, because their 7.2 version has a higher performance than the previous version and made my plugin run much faster without lots of time for processing.

I’d also like to hear from you what else would you like to improve in your day to day job with Symfony2 and NetBeans and who knows may be I will be able to fulfill your expectations.

the bad part

While File templates are working fine, the code templates are not completely working, the only code templates that are working are for php editor, example action template, and others. First the code templates for Twig editor don’t work, I’ll see what I can do with it. Second the code completions for with doctrine annotations are not working, probably because for now I set them as a php documentor templates, may be I’ll need to set them as a php code templates.

The code source is here: https://github.com/Monomachus/UdeviSymfonyPlugin

If you have any questions or suggestions please share them in comments, it will be great to know what you’re thinking about it.

Tuesday, July 24, 2012

Support my feature request for WebMatrix: Possibility to add new file templates

Hello guys,

I used several time WebMatrix for the development using ASP.NET Web Pages, a lot lighter web technology than ASP.NET MVC. Recently I wanted to use WebMatrix 2 to learn Node.js development. Now there is a view engine in Node.js that is called JsHtml. JsHtml is a Razor-like view-engine that can be used with node.js or Express (node.js based Sinatra-like framework). Now back to the point: I saw that files with *.jshtml extension get no highlighting, though it should be similar with *.cshtml or *.vbhtml. I thought that may be I can create an extension for WebMatrix which will somehow call the highlighting engine. Another point would be creating specific JsHTML file template.
But it isn't restricted only to that. It creates and extension point in a free Microsoft product which is used by beginner devs or someone who wants to start playing with NodeJS a little bit.

Actually why I am telling you all these, I created a feature request at WebMatrix UserVoice: Possibility to add new file templates and I voted for it. You can maximum give 3 votes to a feature. Please vote for this feature too, it is important. I would really like these features to get in the top of requested features and than implemented in the final version of WebMatrix 2.

Plus I think these feature can be useful also for .NET devs and I hope you will support this feature request. Thank you.

Wednesday, April 11, 2012

Hibernate : Repeated column in mapping for entity error

Well I guess I need to explain this error so when I’ll get it one more time I’ll at least have a place to see where the problem was.

So I was having this problem because I’ve got an entity and also I’ve got a composed primary key entity that was embedded in the first one.

So let’s imagine I’ve had some GridPreferences entity, that had the GridPreferencesPK composed entity as a primary key which contained userId, and gridId.

GridPreferences.java

@Entity
@Table(name = "GRID_PREFERENCES")
public class GridPreferences extends BaseEntity{
    
    private static final long serialVersionUID = 6521799809955099787L;

    @EmbeddedId
    private GridPreferencesPK id;
    
    @Column(name = "GRPR_GRID_ROWS_PER_PAGE", nullable = false)
    private int rowsPerPage;

}

GridPreferencesPK.java

@Embeddable
public class GridPreferencesPK extends BaseEntity {
    
    private static final long serialVersionUID = 2499336910059865064L;

    @Column(name = "GRPR_USER_ID", nullable = false, precision = 8)
    private String userId;
    
    @Column(name = "GRPR_GRID_ID", nullable = false, precision = 250)
    private String gridId;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "GRPR_USER_ID", insertable = false, updatable = false)
    private User user;
}

Now I got this error  org.hibernate.MappingException: Repeated column in mapping for entity. Which isn’t exactly self-explanatory. But this time Hibernate got it right.

Basically it is an embedded primary key, so it would be logical that all the fields that are in the PK are the fields of the table itself, not the relation tables.

And the solution is to move the connections to other entities into base entity, in our example GridPreference. Doing that will solve the problem.

Hope this will help someone else too.

Thursday, March 8, 2012

New Udevi Symfony2 Template NetBeans plugins that will ease your life (hopefully)

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

1331132011_2012-03-07_1636

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 Sad smile. 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 Smile, 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

1331130368_2012-03-07_1622

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 Winking smile.

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 !