Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mvc design question

I am using Zend framework and doctrine in this app

In my web application i have various individual modules like events, conferences, case studies.. so i am making controller design at this moment. In the below image regulatory document is the controller and its sub are its actions. So regulatory doc, videos, podcasts all are having almost the same kind of functionality. so is this design appropriate...? In mvc for each action i will be having a separate view. And on user type i may have to put access levels on this modules. so i have kept separate controller so that i can easily control the module for each user type. But this is resulting in duplicate code.

enter image description here

Now i am thinking to make one parent class and in that i will have all the common methods. eg. I will have common class Resources and in that i will keep list, search, suggest, addFavorite etc. And that will be the parent to the above given controllers.

So than how will i manage my view for all these different modules if i go with this approach..? if i go with this than my code will be bit messy..?

like image 211
Jaimin Avatar asked Jul 01 '11 09:07

Jaimin


People also ask

What is MVC experience?

MVC is a software architecture pattern for developing web applications. It is handled by three objects, Model, View, and Controller.

What is MVC and example?

The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each of these components are built to handle specific development aspects of an application.

What is MVC life cycle?

The life cycle is basically is set of certain stages which occur at a certain time. Application Life Cycle. MVC actually defined in two life cycles, the application life cycle, and the request life cycle. The application life cycle, in which the application process starts the running server until the time it stops.

What are the four major components of MVC?

So, in fact, there are really four major components in play: routes, models, views, and controllers.


1 Answers

I would suggest to keep all the controllers to have nice URLs and clear structure in the modules, however keep the controllers thin. Put your domain logic into Services or Entities, hence no (or just less) code duplication is required.

More in:

  • Is MVC + Service Layer common in zend or PHP?
  • How to implement service layer in Zend Framework?

From DDD:

  • http://domaindrivendesign.org/node/118

controllers belong to application layer / domain logic belongs to domain layer

like image 64
Tomas Dermisek Avatar answered Oct 21 '22 05:10

Tomas Dermisek