HomePHP Generating View from MySQL to Simulate the Model-View-Controller Schema in PHP
Generating View from MySQL to Simulate the Model-View-Controller Schema in PHP
Are you a curious PHP developer, wanting to learn how to simulate a basic Model-View-Controller schema with PHP? Then, look no further, because you’re in the right place. Welcome to the final part of the series “Simulating the Model-View-Controller Schema in PHP.” In three tutorials, this series provides you with a comprehensive introduction, aimed at implementing a MVC-based relationship between PHP objects.
If you've been one of those readers who has followed the first two installments of this series, then it's highly probably that you know how to define a specific interaction between several objects, which behave separately as a Model, a View and finally a Controller respectively (hence the name MVC).
As you'll possibly recall, over the previous articles I walked you through a couple of hands-on examples to demonstrate how to implement easily the MVC schema with PHP (at least a very basic one). I showed you a basic case that illustrated how to define this type of relationship between a few simplistic message handling classes.
Also, in order to move the schema in question much closer to a real situation, in the second article I developed a quite useful web page generating system, which was capable of attaching on the fly different style sheets, according to the instructions passed by a generic controller object.
Of course, from the very beginning, the goal of this series was to demonstrate how to integrate the MVC schema in PHP. If, however, you're expecting to see something similar to the mechanism implemented in Ruby-on-Rails, then I recommend that you read specific material related to that language and its framework. That is beyond the scope of these articles.
All right, after refreshing the topics covered previously, as well as clarifying some key concepts with reference to the concrete subject of this series, this journey will continue by constructing yet another practical example to expand your overall knowledge of object-based programming with PHP. In particular, it's designed to show you to use a MVC-driven relationship in another real-world situation.
If you're wondering to what other cases this relationship can be specifically applied, then I have good news for you. In this final article, I'll show you how to implement the MVC schema, in order to generate different outputs (or views) from a given MySQL data set.
I'm pretty sure that this experience will be appealing to you, therefore let's see together how this can be achieved with PHP. Let's get started!