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 3623950
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T23:26:49+00:00 2026-05-18T23:26:49+00:00

I use Zend framework and Doctrine. In many projects, business logic is built into

  • 0

I use Zend framework and Doctrine. In many projects, business logic is built into the controller. This approach seems wrong as me.

The best setup I ever saw it is used service layers, and this is where the business logic was written. All I had to do was create a form, validate it, and use some business logic in service layer. Result validation, business logic and work with one method (for example: newProduct($postData)).

What is the right way to organize my business logic in MVC? Maybe I need to read some books, or see some examples of source code.

  • 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. Editorial Team
    Editorial Team
    2026-05-18T23:26:49+00:00Added an answer on May 18, 2026 at 11:26 pm

    I can’t speak for the Zend framework (or for anything you’re working on that was built using it), but in the MVC pattern in general the business logic belongs in the Models.

    You may have heard the statement before that you should “keep your controllers light and your models heavy” (or some variation thereof). The idea is that the Models are your domain (your ubiquitous language) and all business logic should be encoded in them and in their interactions. The controllers are just event handlers in MVC to receive requests and translate those requests over to the Models.

    Edit: (In response to your comment) – I’m afraid we’re having something of a language barrier here. But, to add to the point and hopefully help you with regards to building the model yourself and data being primary, consider a quote by Eric Raymond: “Smart data structures and dumb code works a lot better than the other way around.”

    The idea is that the “logic” is in your data structures, whereby you build a “rich” domain model, complete with logic and functionality. This is as opposed to an “anemic” domain model, which is just flat data structures (or DTOs) that do nothing more than represent a state of data and have no functionality.

    With smart data structures, the code that uses them (which will be in your controllers, as well as various other places) doesn’t need to be sophisticated or complicated. It just needs to tell the Models what’s going on and direct them to do what they need to do. The Models have all the know-how to actually do it.

    This is preferred over “smart code and dumb data structures” where the Models are anemic DTOs (which have their use, don’t get me wrong) and all of the logic is in a more procedural format where each procedure needs to have all of the know-how to perform the business task at hand. This leads to, among other things, lots of code duplication.

    I hope this helps. As I said, I’m having a hard time understanding the full scope of your question.

    Edit: Another thing to consider, since I’m not sure where you were going with the “data is primary” concern. There is a difference between “data structures” and “data persistence” and that difference is absolutely critical here. Your data structures are your Models, enriched with business logic. Your data persistence is the data in the database.

    Very often (all too often, if you ask me), these notions are confused in programming. In most auto-generated code and helpful frameworks and all that stuff, “Models” have a tendency to be direct mappings to database tables and simply represent a record in those tables. This isn’t always wrong, but it is misleading.

    The business logic isn’t in the database. It isn’t in the flat representation of the data. Sure, the database can contain its own persistence logic (such as referential integrity, triggers, auditing that isn’t known to the business logic code, etc.) but it doesn’t contain the business processes that you would normally see in a flowchart of the business logic.

    These concepts may be breaking out of the mold for any given framework’s standard operating procedure. As I said, I can’t really speak for the framework. But personally I tend to advocate “good code” over “popular use of a given tool.”

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

Sidebar

Related Questions

i am currently learning Zend Framework 1.10 and intend to use Doctrine 2. however
I've a question related to Doctrine 2 and Zend Framework. If you use Zend
I've started reading on zend framework and it's use with Doctrine and have implemented
So I use a zend framework, but for all commercial projects I am not
i am developing a Rest Controller using Zend Framework and i have to use
I would like to use ON DUPLICATE KEY UPDATE in Zend Framework 1.5, is
I am searching for a tutorial (optimally with Zend Framework) on how to use
I am learning Zend Framework and Doctrine. I am wondering what is the best
I am looking into using Doctrine2 with my Zend Framework setup. I really like
Though this thread recommends using it, I've few concerns: I started with Zend Framework

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.