smudgie Posted December 29, 2013 Share Posted December 29, 2013 (edited) 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! If MVC is the way to go, what was the old way called? And is this being abandoned due to AJAX and asynchronous loading? 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? 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? Should I use a framework? I would some good sound tutorials first I think?? Any other info, thoughts on MVC would be much appreciated. Edited December 29, 2013 by smudgie Quote Link to comment https://forums.phpfreaks.com/topic/284961-help-understanding-mvc-approach/ Share on other sites More sharing options...
trq Posted December 30, 2013 Share Posted December 30, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/284961-help-understanding-mvc-approach/#findComment-1463237 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.