PHP
  Home arrow PHP arrow Page 7 - Mach-II for PHP: A Preview
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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

Mach-II for PHP: A Preview
By: Mike Britton
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 17
    2004-10-18


    Table of Contents:
  • Mach-II for PHP: A Preview
  • Installation
  • Configuration
  • Properties
  • Event Handlers
  • Basic Coding Techniques
  • Creating Views

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    Mach-II for PHP: A Preview - Creating Views
    ( Page 7 of 7 )

    Views are added to an application by documenting their location in mach-ii.xml, then placing the files in their designated directories (in the demo app’s case the single directory is views).

    Views are called in mach-ii.xml from their respective event handlers. In the demo application, when the form is posted and the processForm listener is called, a successful result calls the showResults event handler. showResults then calls a view.

    <event-handler event="showResults" access="public">
    <event-arg name="pageName" value="Success" />
     <view-page name="results" /> 
    </event-handler>

    Figure 12  ./config/mach-ii.xml ~ calling a view

    It’s a good idea to create views that are as generic as possible so a single view can be used in many different event handlers. One obvious approach is to think of each view as a ‘component’ rather than a ‘page’. Mach-II is great for component-based layouts because <view-page> can specify its content be copied to a variable rather than display a view outright. In this way, multiple views can be generated in an event handler using the optional contentKey attribute:

    <view-page name="menu" contentKey="GLOBALS['menu']" />
    <view-page name="subMenu" contentKey="GLOBALS['subMenu']" />

    Figure 13  ./config/mach-ii.xml ~ mapping views to global variables

    The demo application’s results.php displays the result from the processForm listener’s validate method:

    <? echo $GLOBALS['results']; ?>

    Figure 14  ./views/results.php ~ Displaying the results from listener processForm

    results.php also displays an <event-arg> defined in mach-ii.xml for the event showResults:

    <? echo $event->getArg('pageName'); ?>

    Figure 15  ./views/results.php ~ Displaying an <event-arg> defined in mach-ii.xml

    The display file results.php:

    <? $page = $event->getArg('pageName'); ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "
    http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title><? echo $page; ?></title>
    </head>

    <body>
    <table cellpadding="0" cellspacing="0">
     <tr>
      <td align="left" valign="middle">
      <? echo $GLOBALS['results']; ?>
      </td>
     </tr>
    </table>
    </body>
    </html>

    Conclusion

    There are many more topics to cover that are not within the scope of this article. Among them are plugins and filters that make it possible to manipulate Event data (you’ll see them in mach-ii.xml).

    Mach-II offers developers a fast, efficient and easy-to-maintain framework for object-oriented applications in PHP.  At the time of the writing, Mach-II for PHP5 is in testing and will be available soon. For developers searching for a standardized design methodology for PHP web apps, Mach-II is a superior choice.



     
     
    >>> More PHP Articles          >>> More By Mike Britton
     

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





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