Wait, What? Which Way Already???


I thought I was trucking along pretty well with Zend (ZF2), but in discussing our progress, I've come to realize that my partner's code is completely different from mine.  I've been using the first tutorial (the "Album" one) as a guide while he used the second ("the task list) which I mostly skipped over because it required using Zend Studio and didn't include all of the code on the presumption you generated it with that. For example, I have things like Formats and FormatsTable in my model while he might have FormatsDAO (which is what he called the mapper to more closely mimic what we do with Mach-II) and then a separate Entity folder with Format.  The code in them are very different as well.  He has a mapper and the like,

While reading the ZF2 docs for figuring out how to implement some of our form formats and the like, the code there on adding form elements are completely different from what they show you in the tutorial!  Same thing with some of the database stuff.  And some of that is different from what they show in their video tutorials and stuff.

I've tried Googling for what is considered "best practice" and it doesn't seem like people talk about that very much or my Google-foo is failing me badly. It doesn't help that Google keeps giving me results for both Zend 1 and 2 at the same time and people who post examples are not always clear on which one they used.  When looking at how the code is organized, again the two tutorials show different ways and then many of the top experts show something different structures. The tutorials have you make a new module for your application, while many Zend experts seem to recommend putting it all in the Application folder unless it is an autonomous bit of code, basically a plug-in of sorts, that can be easily dropped into another app. The tutorials have you make individual folders for each model of the app, i.e.

— module
    — MovieShelves
        — src
            — Formats
               — Controller
               — Form
               — …
            –Genres
                — Controller
                — Form
                — …

While most apps that I've seen that refer to good quality to it more like this:

— module
    — MovieShelves
        — src
            — Controllers
               — FormatController.php
               — GenreController.php
            — Forms
            — Entities
            — …

Since Zend 2 has been out for 4 years, I would better coverage and documentation out there.  The one result that seems to come up the most is just a copy of the official docs.  And the official docs have some rather sucky parts.  The navigation is horrendous, a few pages people have noted are actually ZF1 examples, and for functions with limited options the docs don't tell you what those options are. I shouldn't have to dig through the ZF2 source code just to find out what options something takes.

To be clear, unlike with Cake, I am still liking the Zend framework a lot.  And once I do find an answer on "how do I…", I can usually understand it.  My frustration now is purely on the documentation and seeming lack of cohesion in the community.  Yes, we like it being flexible, but we also do still like knowing what the recommended best practices are to use as guiding posts in deciding how we want to do things.  And yes, I can understand Zend not giving their docs their full focus as they would probably rather you pay them the $1,000-$3,000+ it costs to take their courses ($1,000 for one, $3,000 for the money saving bundle that includes the PHP certification exam).  I've come to realize the reason people said it is so hard to learn isn't because it is really hard, but because the lack of good quality documentation makes trying to learn a much bigger burden.

So at this point, I'm thinking it's time to buy one of the books, as they at least have more complex examples than the two tutorials and often include the "why" behind some things. Or just saying screw it, what do we like and let's just do that.