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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:22:19+00:00 2026-05-28T02:22:19+00:00

Introduction The Model-View-Controller approach has been in my head since before the holidays and

  • 0

Introduction

The Model-View-Controller approach has been in my head since before the holidays and I really need to get it down to a tee within my web application, created in PHP.

So far, I understand the general MVC Concept and why it’s done, but I need some help. This is a University project, and my project adviser is not very helpful when I ask questions about MVC.

The Application

It’s a task management system, or a to-do list. The aim is a very simple interface where the user can login with their Facebook account, create, modify or remove tasks, and logout, created with Javascript and PHP.

The Facts

I have a static PHP page here containing divs like “top_div” and “main_div”. The aim is for “controller.php” to be included (I haven’t created this yet) to serve between the view and the model.

Important: Everything on the page uses jQuery, so the user will never see a page refresh. I have a function that fades out the content in a div, grabs the newly required content, places it in the div (hidden, because the div has faded out), then fades in the div again.

The aim is for the controller to request from the model, then send back (for example) a Facebook login button to the view. This Facebook Login button is HTML. There will be others like text and html for the content, and if the user is already logged in “Welcome ” will be sent to the #main_div using PHP, jQuery and cURL.

I am using objects, so from what I understand I will need to instantiate an object to do the database connection and queries. Where do I instantiate objects? I read that they are supposed to be created in the controller, but from everything else I’ve read the controller is meant to be simple, telling the model what the view wants acting only as the go-between. I was under the impression (and it makes more sense to me) for the model to instantiate objects.

1) So, please explain to me how it would be incorrect to instantiate objects in the model. If this wasn’t the case, that’d be great as far as my understanding of the MVC approach goes.

Lets say the user has logged in. I will be displaying their name, and their Facebook picture on the view (index.php). If you visit the site on the link above you may see a small white box on the right where this picture will go. The code for the user’s picture in PHP looks like this:

<img src="https://graph.facebook.com/'.$fbid.'/picture" width="79" height="64" align="center" style="opacity:0.8;">';

2) As this HTML will be passed to the view to be displayed into a DIV using the jQuery function described above, is it okay for my controller to have this sort of information going out? My controller may have something along the lines of (pseduo code):

if(user is logged in(from checking via model)) then { send to #main_div the html above };

I may think of loads more questions along the way with this, but please can someone help me understand more about what I’m doing?

  • 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-28T02:22:19+00:00Added an answer on May 28, 2026 at 2:22 am

    1) So, please explain to me how it would be incorrect to instantiate
    objects in the model.

    It’s not incorrect at all. The goal is thin controllers and fat models, however, so I do object creation in my controllers and let the models/services do the heavy lifting.

    Caveat: It’s best to do object creation somewhere else, in a bootstrap, perhaps, and use dependency injection to feed those objects to your controllers. That being said, much of my object creation happens in the controller as needed.

    2) As this HTML will be passed to the view to be displayed into a DIV
    using the jQuery function described above, is it okay for my
    controller to have this sort of information going out?

    Yes, it is. The controller will pass data from your model to the view.

    MVC framework recommendations

    Unless you just want to, or have to, don’t roll your own MVC. Pick a framework, do a little studying, and win.

    • Slim
    • Aura
    • Symfony
    • Zend
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm finding it really difficult to find an introduction to the object model used
Introduction I've always been searching for a way to make Visual Studio draw a
Introduction I have been so annoyed by applications that have a startup dialog which
Introduction: I'm trying to get additional fields to log with log4j, and its working
Introduction to the problem I have been taught about OO Analysis and Design through
Introduction Google chrome has a feature that allows you to create shortcuts to web
I have been working on the introduction on the link below and have been
essentially what I'm trying to do is get my head around Microsoft's ASP.NET MVC
I've not used Unit Tests before other than a quick introduction in a Uni
I'm a TA for an Introduction to MATLAB course, and the class has not

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.