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.
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.
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:
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.