List Info

Thread: MVC in action




MVC in action
user name
2006-07-27 12:43:30
Just wondering how do you implement MVC pattern using ZF in
practice.
Lets take a case of form submission.

So there is
TestController extends Zend_Controller_Action{
showformAction() {}
processformAction() {}
}
and the form is submited to test/processform

This is not too good because on complex sites a simple
controller can
become pretty robust and hard to mantain (for example user
area of an
application where there is pretty much actions)
-----------------------
OR
-----------------------
With 2 controllers 1 for handling view part and another for
command
(which I personaly think is closer to MVC pattern)

TestController extends Zend_Controller_Action{
showformAction() {}
}

TestController_c_ extends Zend_Controller_Action{
processformAction() {
  .. and on success redirect somewhere, on failure back to
view controller..
}

-----------------------------------
I need to ask this before jumping in coding and regret at
the end. I
managed to integrate Flexy, working on LiveUser, but I am
quite new to
ZF. So shoot please
MVC in action
user name
2006-07-27 13:12:06
It really depends on the complexity of your controllers.  I
generally
place the get and post methods in the same controller so I
would have a
showFormAction and a showFormPostAction.

Now if the forms were very complex then I would have these
methods hand
off control to other helper classes to do most of the heavy
work.  Try to
keep the controller classes reasonable in size.

But I am curious to see how many developers would always use
two controllers.

>
> Just wondering how do you implement MVC pattern using
ZF in practice.
> Lets take a case of form submission.
>
> So there is
> TestController extends Zend_Controller_Action{
> showformAction() {}
> processformAction() {}
> }
> and the form is submited to test/processform
>
> This is not too good because on complex sites a simple
controller can
> become pretty robust and hard to mantain (for example
user area of an
> application where there is pretty much actions)
> -----------------------
> OR
> -----------------------
> With 2 controllers 1 for handling view part and another
for command
> (which I personaly think is closer to MVC pattern)
>
> TestController extends Zend_Controller_Action{
> showformAction() {}
> }
>
> TestController_c_ extends Zend_Controller_Action{
> processformAction() {
>   .. and on success redirect somewhere, on failure back
to view
> controller..
> }
>
> -----------------------------------
> I need to ask this before jumping in coding and regret
at the end. I
> managed to integrate Flexy, working on LiveUser, but I
am quite new to
> ZF. So shoot please
>
>


MVC in action
user name
2006-07-27 13:36:02
I just tought about divide in 2 controllers, because
previous MVC that
I used was Tony Bibbs (wonderful guy) MVCnPHP which
completly
separated commands from views. I didnt saw why until the
contractor
asked for various redirections between commands, and showing
more
views in a row (wizard like funtionality).

Tought about adding _c_ suffix for an action, because on
errors in
form it can almost automatically show its view (can extract
view from
action name), maybe extend controller class with some
_redirectViewAction($calling_fnc_name) function .
Again just wondering, but rather now than with 20
controllers in place
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )