PHP
  Home arrow PHP arrow Building a Web Page Controller for Sim...
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building a Web Page Controller for Simulating the Model-View-Controller Schema in PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 11
    2006-08-14

    Table of Contents:
  • Building a Web Page Controller for Simulating the Model-View-Controller Schema in PHP
  • Creating the first component of the schema: defining a web page controller class
  • Creating a real-world model: defining a web page generator class
  • Completing the MVC schema: defining a style sheet generator class
  • Putting the MVC schema to work: generating style sheets on the fly

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


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


    (Page 1 of 5 )

    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.

    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


       · The second article of this series demonstrates how to use the MVC pattern, in order...
       · It seems that you don't understand the MVC pattern well.
       · Thank you for commenting on this PHP article. I do accept your criticism, but the...
       · I wish MVC was that simple. It is not though. But I still think your article is...
       · Thank you for the comments on my PHP article, and I'm glad to know it was useful...
     

       

    PHP ARTICLES

    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter
    - Building Your Own System Tray Application Us...
    - Structuring Your Projects for Web Applicatio...
    - Inserting, Updating and Deleting Database Ro...
    - Building Your Own Desktop Notepad Applicatio...
    - Web Application Security Overview
    - Working with the Active Record Class in Code...
    - Generate PDF Documents with PHP on the Windo...
    - Sending Email with PHP Networking
    - Performing Strict Validation with the Code I...
    - The preg_replace_callback() function in PHP
    - PHP Networking
    - Validating Web Forms with the Code Igniter P...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT