Home arrow PHP arrow Page 3 - Mach-II for PHP: A Preview

Configuration - PHP

Mach-II is a framework for organizing applications using standard OO techniques. This article will cover how to install, set up and configure a Mach-II application, and explore basic coding techniques.

TABLE OF CONTENTS:
  1. Mach-II for PHP: A Preview
  2. Installation
  3. Configuration
  4. Properties
  5. Event Handlers
  6. Basic Coding Techniques
  7. Creating Views
By: Mike Britton
Rating: starstarstarstarstar / 17
October 18, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Programs that use implicit invocation are frequently referred to as event-driven or event-based. Events are announced, and listeners respond if they are subscribed to them. This is how Mach-II works.

In order to understand what is meant by this, we should begin with mach-ii.xml. This is the configuration file used to define event relationships in a Mach-II application.

<!--
    phpMachII
        config
            mach-ii.xml
   
    I define the basic control flow for this demo application.
-->
<mach-ii>

    <!-- PROPERTIES -->
    <properties>
        <!-- MACH II REQUIRED -->
        <property name="defaultEvent" value="showMain" />
        <property name="exceptionEvent" value="exception" />
        <property name="applicationRoot" value="/phpMachII" />
        <property name="eventParameter" value="event" />
        <property name="parameterPrecedence" value="form" />
        <property name="maxEvents" value="10" /> 
    </properties>

    <!-- LISTENERS -->
 <listeners>
  <listener name="processForm" type="phpMachII.model.processForm">
   <invoker type="MachII.framework.invokers.ObjectEvent" />
  </listener>  
 </listeners>
   
    <!-- EVENT FILTERS -->
    <event-filters>
  <event-filter name="GlobalsToEvent" type="phpMachII.filters.GlobalsToEvent" />
    </event-filters>

    <!-- EVENTS -->
 <event-handlers>
 
  <!-- Main (landing page) -->
  <event-handler event="showMain" access="public">
   <event-arg name="page" value="Main" />  
   <view-page name="main" />
  </event-handler>
 
  <!-- Process a few form variables for demonstration purposes -->
  <event-handler event="processForm" access="public">
   <event-mapping event="success" mapping="showResults" />
   <event-mapping event="noSuccess" mapping="showMain" />
   <notify listener="processForm" method="validateForm" resultKey="GLOBALS['results']" />
  </event-handler> 
 
  <!-- Display results of form processing -->
  <event-handler event="showResults" access="public">
   <event-arg name="pageName" value="Success" />
   <view-page name="results" /> 
  </event-handler>
   
  <event-handler event="exception">
   <event-arg name="page" value="Failure" />
   <view-page name="exception" />
  </event-handler>
 
 </event-handlers>

    <!-- VIEWS -->
    <page-views>
 <page-view name="main" page="/views/main.php" />
 <page-view name="results" page="/views/results.php" />
        <!-- Exception -->
        <page-view name="exception" page="/views/exception.php" /> 
    </page-views>
   
    <!-- PLUGINS -->
    <plugins>
    </plugins>

</mach-ii>

Figure 3  The demo app’s mach-ii.xml structure

This file is the control center of a Mach-II application. As you can see by looking at our example’s mach-ii.xml file, the application is composed of properties, listeners, event-handlers, plugins and filters. mach-ii.xml is where you define the properties and relationships that make up your application. It can be found in an application’s /configure/ directory.



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

blog comments powered by Disqus
   

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

 



© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap

Dev Shed Tutorial Topics: