Jump to content

Recommended Posts

Hi,

 

Can someone please help me get my head around this MVC approach? I'm new to PHP and I've been led to believe MVC is the way to go for asynchronous re-loading and re-useable code. Sorry to be so naive about the following, but if I could get some answers this would really help!

 

  1. If MVC is the way to go, what was the old way called? And is this being abandoned due to AJAX and asynchronous loading?
  2. It’s hard to find a tutorial that directly says ‘PHP MVC approach’ for some reason, any suggestions of sites, books which directly show you how to implement this approach using AJAX and JSON would be welcomed?
  3. I take it, if created for say a login on an app, the code could be directly transferred to a responsive site without much alteration?
  4. Should I use a framework? I would some good sound tutorials first I think??
  5. Any other info, thoughts on MVC would be much appreciated.
Edited by smudgie
Link to comment
https://forums.phpfreaks.com/topic/284961-help-understanding-mvc-approach/
Share on other sites

1) MVC has nothing at all to do with Ajax, though you can make ajax request (as normal) to an application built using the MVC design pattern.

2) MVC is a design pattern. A documented solution to a common problem.

3) MVC separates your application into at least three layers. The model layer, the view layer and the controller layer. Hence, making changes to the view layer should not effect the other two layers.

4) Yes. Pick a framework and start with its documentation.

5) The MVC design pattern itself is very simple, but implementations (most frameworks) tend to be fairly complex because they tend to solve more than a single problem (and therefor also implement many other design patterns in the process). If your just getting started, I would suggest getting your head around OOP in general before diving into design patters. While the MVC pattern can be implemented in procedural code, its not common practice and any framework you find using it will indeed be OOP.

 

If your really keen to learn about this stuff (and you should be). Fabien Potencier (the original creator of the Symfony framework) has an excellect series on creating your own framework based on Symfony's components. (available here). While this series will likely take you a solid week to get through it is an awesome resource for learning about the architecture of a modern framework and by the end of it you will have built your own small framework that implements the *controller* part of MVC.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.