Why should I use MVC on php website?

Many frameworks are based on mvc, but I have no idea about MVC. So what is the use of MVC? Is it for speed, safety or for any other reason?

+4
source share
3 answers

MVC allows you to separate your business logic from the presentation level. This “Problem Separation” allows you to quickly find and edit parts of your code. It also makes it easy to reuse user interface components on your system.

Check out the wiki page for an overly academic and technical introduction to MVC http://en.wikipedia.org/wiki/Model_view_controller

+6
source

MVC basically provides the best maintainability of your code. By separating database logic from data presentation logic from controller logic, you can easily / easily change / overwrite / maintain.

+2
source

it also solves the problem of “spaghetti code”, you can transfer your HTML / XML / PDF / XSL creation code to your view / template engine, get data from your model (DB / File / RemoteCall, ...), and your controller controls the behavior of both, you can also simply exchange View / Models, without even changing the Controller, if you implement it correctly, so that you get Seperation of Concerncs, improve code and maintainability, and can easily change components are also easier to manage if your projects grow. I recommend using FrontController, which selects the right controller for you, depending on user input, you can also use Inversion of Control / DependencyInjection Pattern, and let your controller be configured with your FrontController / Pass DB connection and lots of lots more fun stuff Now you have simple application framework :) Use Zend instead :)

+1
source

All Articles