Skip to main content

jMaki supports PHP!

Posted by gmurray71 on November 29, 2006 at 4:10 AM PST

I am proud to announce that jMaki now has a server runtime that fully supports jMaki for PHP 5. This is in addition to JSP, JSF, and Phobos.

What does this mean for Java developers?

You now have the choice to script the front ends of your web applications on standard PHP. Your back end services can remain in Java which is well equipped for handling your transaction processing, messaging, and web services. If at some point you need Java for your services we can provide that too.

What does this mean for PHP developers?

You now have a simple way to build Ajax style applications using client centric JavaScript. jMaki is a framework that provides CSS layouts, widgets, and the glue to tie everything together. Out of the box you can use Dojo, Yahoo UI, Scriptaculous, and many other libraries together with a simple PHP call. To use jMaki you simply unzip a file into your PHP 5 web directory.

What does jMaki PHP code look like?

<?php require_once 'Jmaki.php'; ?>
<?php addWidget('dojo.tree', 'tree.json');

The example above creates a Dojo tree which consumes a tree.json file that defines the tree data.

A more advanced example:

<?php require_once 'Jmaki.php'; ?>
<?php addWidget('dojo.table', null, null,
"{ columns: { title : 'Title', author:'Author', isbn: 'ISBN #', description:'Description'},
['JavaScript 101', 'Lu Sckrepter','4412', 'Some long description'],
['Ajax with Java', 'Jean Bean','4413', 'Some long description']

Here is a screen shot just in case you do believe it works.

jMaki Glue Example in PHP

Now lets look at a more advanced example using two widgets that communicate with each other by publishing events that are intercepted by some glue JavaScript code which you can define the action to take.First lets look at the PHP to define the Yahoo Map and Geocoder.

<?php require_once 'Jmaki.php'; ?>
addWidget('', null, "{centerLat:37.39316, centerLon:-121.947333700, height:300}");
<?php addWidget('yahoo.geocoder', '../XmlhttpProxy.php');

The Yahoo Geocoder publishes a event which is mapped in the jMaki config.json file to call the function jmaki.listener.geocoderlistener. The code from the config.json is as follows:

 "glue" : {
    "includes": ["glue.js"],
    "listeners": [
       {"topic" : "/yahoo/geocoder",
        "action": "call",
        "target": {
                 "object": "jmaki.listeners",
                 "functionName": "geocoderListener"

The following Glue JavaScript is provided by default in jMaki so you don't have to tie the widgets together yourself.

  jmaki.geocoderListener = function(coordinates) {
      var keys = jmaki.attributes.keys();
      for (var l = 0; l < keys.length; l++) {
          if (typeof jmaki.YahooMapWrapper != 'undefined' &&
               jmaki.attributes.get(keys[l]).constructor == jmaki.YahooMapWrapper ) {
              var _map = jmaki.attributes.get(keys[l]).map;
              var centerPoint =
              new YGeoPoint(coordinates[0].latitude,coordinates[0].longitude);
              var marker = new YMarker(centerPoint);
              var txt = '<div style="width:160px;height:50px;"><b>' +
                 coordinates[0].address + ' ' + coordinates[0].city + ' ' +
                 coordinates[0].state + '</b&ht;</div>';

The graphic belo shows the resulting widgets.

Where to go next:

Download the jMaki for PHP from the jMaki Downloads Page.

Provide feedback at the jMaki Forumns.

Learn more aboutjMaki for PHP at the jMaki Home Page.

Learn more about
">jMaki Glue.

What else would you like to see jMaki and jMaki PHP do?

Related Topics >>