DreamerX Posted March 20, 2011 Share Posted March 20, 2011 I heared alot about MVC. What is it? and is it easy to learn? What do I need to write PHP code with MVC in mind, do I need to learn about Frameworks? And finally could you tell me about a good book for PHP and MVC or a good website for totally beginner? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/231163-what-is-mvc/ Share on other sites More sharing options...
Zyx Posted March 20, 2011 Share Posted March 20, 2011 It's an architectural pattern, or - in other words - a well-tested recipe, how to organize the structure of your application in order to get certain benefits. You can implement it yourself, or use an application framework that does it for you. If you do not know what design and architectural patterns are, you should try to learn something about object-oriented programming and object-oriented design. MVC is an ancestor of the whole family of patterns. In the webdevelopment circles, most articles claiming they describe MVC, actually describe one of its distant descendants. Quote Link to comment https://forums.phpfreaks.com/topic/231163-what-is-mvc/#findComment-1189836 Share on other sites More sharing options...
ignace Posted March 20, 2011 Share Posted March 20, 2011 MVC stands for Model-View-Controller and like Zyx pointed out it's an architectural pattern. MVC is an example of good Separation of Concern (SoC), each part has a clear responsibility. For the View this is rendering the interface, and communicating changes to the Model (at least in it's original design, for PHP this will be the Controller due to the View being remotely manipulated). The Model does the actual work. For example, I am typing this text in this textarea and when I submit it, the text will be passed to the Model and in turn will insert it into some data store. And upon you visiting this page, will retrieve it. The Controller ties the Model and the View together in order to handle a request. For example, when you open Excel and choose File > Open a dialog appears, the Controller handled the request (I want to open a file), the Model loaded the files under a certain directory and the View rendered the dialog (when you click on a directory, the View will communicate this change to the Model and it will load the new directory contents). In PHP this would be that you visit /user/edit/1 which indicates you want to edit a user with ID #1, the Model will retrieve the user from the database with ID #1, the View will render the form. And when you submit it will be passed back to the Controller, which passes the POST data to the Model to store it in the data store. Like I said earlier, the MVC is different for local and remote apps. Quote Link to comment https://forums.phpfreaks.com/topic/231163-what-is-mvc/#findComment-1189864 Share on other sites More sharing options...
macross Posted March 20, 2011 Share Posted March 20, 2011 DreamerX i assume you know what is OOP, if thats the case, then check out this tutorial http://net.tutsplus.com/tutorials/php/create-your-first-tiny-mvc-boilerplate-with-php/ Quote Link to comment https://forums.phpfreaks.com/topic/231163-what-is-mvc/#findComment-1190015 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.