Laravel / Basics / MVC Framework
MVC Framework
-
Step
Traditional approach
Let us write a program using traditional approach
class student { public $mark; function grade($ab,$bb,$cb,$db) { $marks=$ab+$bb+$cb+$db; if ($marks>=60) { $grade = "First Division"; } else if($marks>=45) { $grade = "Second Division"; } else if($marks>=33) { $grade = "Third Division"; } else { $grade = "Fail"; } return $grade; } function report_card($aa,$ba,$ca,$da) { $grd= $this->grade($aa,$ba,$ca,$da); echo " report card subject grade mathematics: ".$aa." physics: ".$ba." chemistry: ".$ca." english: ".$da." total grade: ".$grd." During, traditional approach of programming, the UI coding, business logic and applications data domain was written into a single file which creates lack of maintainability, testability as well as scalability of the application. SOLUTION:
In MVC pattern, The UI logic belongs in the view. Input logic belongs in the controller. Business logic belongs in the model. This separation helps you manage complexity when you build an application, because it enables you to focus on one aspect of the implementation at a time.
MVC approach
MVC Example