Sunday, September 8, 2013

A bit of fun with Zend Framework 2

After writing web applications in Java for about ten years, we recently approached PHP. After a bit of training and experiments on the Zend Framework 1, before starting to actually work on a real product we decided to switch to the Zend Framework 2 (mostly because of a great Zend Framework Day).
But it was only after a few months that my colleagues had started to use the framework that I eventually joined them.

At the beginning it was really frustrating. After ten years of Java, getting "back" to PHP has been somehow weird: I kept using dots instead of arrows, always forgot the dollar sign before variables, yet insisting on declaring their types. Not to mention the syntax to declare and use arrays (which, to tell the truth, I never remember also in Java). But these were not problems, just minor diversions.

My real problem was that I didn't know what happened under the hood, and I mostly proceeded tentatively. In the Zend Framework 2, of which by the way I have quite a good opinion, so many things happen automagically, and some of them are not very well documented. I mean, thanks for a great tutorial for beginners and all, but... why on earth do I have to create an album/album directory for the view? Would it be so terrible to say that there is a folder for the module and one for the controller? Or to explain how camel case turns to dashes and dashes turn to... what do they turn to?

And so, even the simplest tasks seemed daunting. Then, after banging my head on the wall for a while, I slowly started to get the gist of it, up to the point that now I feel quite confident, at least for the basic things.

And then, suddenly (snaps glove), you get a break... all the pieces seem to fit into place

And, hear, I started to enjoy playing with it: controllers, factories, autoloading... and, last but not least, tests. And (and, even if this was the fifth and in such few a lines, I somehow managed to slap in a sixth and a seventh one) I slowly switched from "how the hell do I get this parameter from the route?" back to "where should I put the responsibility of horizontally filtering data"?

Up to the point that I am seriously considering the possibility to REALLY get way out of my comfort zone and submit a proposal for one of the next conferences introducing the framework for beginners like me, trying to smooth the path I have lightly trodden with so many difficulties.

Hey, maybe it's only me, maybe I'm particularly dumb... but then again, somebody could find it useful. As always, I'm wide open for suggestions... but closed for modification :-)

As an end note, I'd like to thank Antonio for being so patient and putting up with my musings, questions and doubts. Looking forward to some more programming fun time together!