Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 131847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:10:11+00:00 2026-05-11T06:10:11+00:00

I have a question that really applies to any MVC framework, I’m using the

  • 0

I have a question that really applies to any MVC framework, I’m using the Zend Framework MVC.

When exactly should you create a new controller? What exactly should the Controller layer define?

I’ve created several apps with the MVC, progressively becoming more reusable, but I’ve always struggled with naming Controller classes. For the most part it matches whatever URL requests there are, so business/front end logic. But in some cases it seems totally arbitrary.

Does anybody have some heuristics/guidelines to follow? Seems like with all the hype about MVC, especially with PHP, there is little data on actual conventions and heuristics. As it’s pretty easy to create a disorganized MVC application…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:10:11+00:00Added an answer on May 11, 2026 at 6:10 am

    I generally have one controller for each logical group of functions. Often this will correspond with one controller per model, sometimes not.

    Imagine you’re creating a simple online catalog that displays a list of categories then when the user selects a category, displays a list of products from that category, along with an admin panel for CRUD operations on categories and products. I’d have two models (CategoryModel and ProductModel). I’d have a controller which generated the category listings for the front end, and another controller which generated the product listings (e.g. CategoryController and ProductController). I’d then have a controller for categories and products on the back end (AdminCategoryController and AdminProductController). The two back end controllers would handle list/add/edit/delete/view operations for their respective models. If you think though your URL structure and put related functions on related urls, then your controller structure will often match your URL structure. In fact some frameworks (e.g. CodeIgniter) route requests based on the name of the controller as default behavior.

    As for what goes in the controllers, I work in the idea that Models are for data access, and wrap and hide the database structure. Logic such as ‘assign the current time to completion_date when status is set to ‘complete” is a great fit models.

    Views contain the entirety of your presentation. Controllers/Models shouldn’t generate or handle HTML. Decisions such as 2 columns or 3 belong in views. Logic in views should be restricted to that which is required to generate the visible output. If you find yourself wanting to query the database from a view, you’re probably putting too much logic into the view.

    Controllers are for what’s left. Generally that means, validating input, assigning form data to models, selecting the right views and instantiating the models required to handle the request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.