From the course: PHP: Design Patterns
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
The model-view-controller pattern in action - PHP Tutorial
From the course: PHP: Design Patterns
The model-view-controller pattern in action
- And here's a framework-based implementation using the Slim micro framework. Once again, the framework is already installed by a composer in your vendor directory. You can just run the example. You should notice that it's effectively identical with what we had before. Because of Slim, we have some improved routing capabilities, but otherwise things work effectively the same as they did before. In this case, we captured the incoming get and routed it to our controller that we had before. We still used module to choose which controller we want to use. In this case we're back to the NumberController. Once we have the contents of the request into the closure, we route it just like we did before. We create the controller and pass the parameters along. The controller itself is unchanged from our earlier example, in that it passes the data along to the model, chooses the view, and combines the two for the output. Finally, the model and view are unchanged also. They simply take the input…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Introducing the model-view-controller pattern2m 30s
-
(Locked)
Exploring a use case for the model-view-controller pattern2m 37s
-
(Locked)
The model-view-controller pattern in action1m
-
(Locked)
Challenge: Apply the model-view-controller pattern59s
-
(Locked)
Solution: Apply the model-view-controller pattern1m 41s
-
(Locked)
-
-
-
-
-
-