Chapter 8: Model, View, Controller (MVC) Example
In this chapter, we're going to learn about the Model, View, Controller (MVC) pattern by building our own toy MVC system. We'll start off by revising what MVC actually means. With that understanding in place, we will then work through creating our own toy version – starting off with the Controller layer to handle requests, then the Model layer to work with data, and finally the View layer to render some HTML.
We will actually run the code and confirm that it all works with some test code to simulate a browser visit and the PHPUnit test class to confirm it really is all working.
This chapter will cover the following main topics:
- Model, View, Controller – MVC
- Controller
- Model
- View
- It lives
As usual, you can find all the code samples for this chapter in the main repo for the book available on GitHub at https://github.com/PacktPublishing/The-Art-of-Modern-PHP-8