Home arrow PHP arrow Building a Web Page Controller for Simulating the Model-View-Controller Schema in PHP

Building a Web Page Controller for Simulating the Model-View-Controller Schema in PHP

If youíre one of those PHP developers that want to extend your background in object-based applications, then this series might be quite attractive to you. In these three tutorials (of which this is the second), youíll learn how to simulate a simple Model-View-Controller schema, which can be easily expanded to construct more complex relationships between the different entities, in this case applicable specifically to PHP classes.

TABLE OF CONTENTS:
  1. Building a Web Page Controller for Simulating the Model-View-Controller Schema in PHP
  2. Creating the first component of the schema: defining a web page controller class
  3. Creating a real-world model: defining a web page generator class
  4. Completing the MVC schema: defining a style sheet generator class
  5. Putting the MVC schema to work: generating style sheets on the fly
By: Alejandro Gervasio
Rating: starstarstarstarstar / 11
August 14, 2006

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

Stepping back for a moment to the first tutorial of the series, youíll certainly remember some of the topics that I discussed before. First of all, I went through the basic concepts of how to define and implement an MVC (Model-View-Controller) relationship between classes, by developing a simple and practical example.

As youíll surely recall, this example consisted basically of three separated classes, where each one was originally defined to fit the requirements of a highly-generic MVC schema. In this case, the first class was built as a basic message controller class, then the second one (the model) was constructed to behave like a simple message saving mechanism, and lastly the third one was responsible for generating different views (lowercase, uppercase and reversed, respectively) from an input string passed as an argument to the controller class.

Of course, itís not my intention here to develop a full-featured MVC schema like the one used in Ruby on Rails, but instead provide you with an easy-going introduction to simulating this relationship by the means of some concrete PHP classes. From that point onward, you can expand the model, and develop more sophisticated applications.

Well, assuming that this introduction has refreshed most of the concepts deployed in the previous tutorial, the next step on this journey consists of implementing the MVC schema in the context of a real-world application. We're going to build a web page controller system, which will be capable of creating different style sheets on the fly. In this way it will generate several views from the same model, that is the web document in question.

The experience will be really educational, therefore letís continue learning how to implement a more realistic MVC relationship with PHP. Letís get going!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: