Hi Simon,

SiCo007 schrieb:
I am kind of in the same boat here, I find it frustrating that ZF doesn't
handle or suggest a use of models. I fully understand why mind you now I
have investigated, a model is essentially what anyone wants it to be!!

Well, that's a very differently handled issue.
Most PHP programmers treat models like the connection of a db to controllers. But from a design view they could be virtually anything, indeed they are a *Model* of your requirements. And for that how you would integrate a model of everything into a general framework like ZF?
You can't.

It seems to me that a lot is put into the controller in the docs and the
framework as a whole but that most of the actual work should actually happen
in the model!

It should, yes. A controller is best viewed as an application that uses stuff from the model. If you create another client beside HTTP, like a CLI it should use the same functionality out of the model. That's the easiest way to see a model and a controller: the model is the core of your application, the controller is just your application layer, your API to the core.

I would like to see a base class and maybe a best practice / example in the
docs as a getting started, it's been my biggest hurdle choosing what
metodology (read opinion) to follow over model useage!!

Like I said before: there a billion different applications and many thousand clients possible.
So how you could make a base class for every one of it?
You easily can't.

Google for stuff like modelling domains, layered architectures and application design.

A three-layer application could be seen as:

Top: UI, Webpage, CLI, API, Whatever client
Middle (Core): your concrete application
Bottom: Infrastructure (DB, Filesystem, Mails, XML,...)

That's a minimum layered application.
If you want to know where a specific method or class belongs in, you could ask yourself: "Do all clients have to use this method?". If the answer is yes, it is a core functionality and belons to the middle layer. If there are differences betweens clients (e.g. a CLI can't use web forms) it belongs to the top layer. That's the responsibility of a controller (or helper classes) of MVC then, and to delegate the work and make calls to the core.







Reply via email to