jMaki, PHP and GlassFish - again using Caucho Quercus
jMaki is a light-weight framework for build Web 2.0 applications. It provides support for multiple languages - Java (1, 2, 3, 4, 5, 6) , PHP, Ruby (1, 2), Phobos (1). The numbers in parentheses indicate the entries that I've created showing jMaki support for that language. As evident, I've not created a single entry for PHP yet. This entry is going to change that :)
This entry shows how to deploy a jMaki-enabled PHP web application in GlassFish. It builds upon an earlier entry that showed how to deploy a simple PHP application in GlassFish.
- PHP-enable GlassFish and verify it's working correctly following these steps.
- Build, Install and Run a simple jMaki/PHP sample
- Download and Unzip the contents of
jMaki/PHP release (0.9.7.2 as of this writing). This creates "
jmaki-php-0.9.7.2\jmaki-php" in the current directory. - Go to "
jmaki-php-0.9.7.2\jmaki-php\core" and invoke "ant". This creates "dist\jmaki-core.zip". - Unzip the contents of "
jmaki-core.zip" under the "web" directory of the project created in the link followed from first step. - Redeploy your project and your first jMaki widget in a PHP page deployed on GlassFish is now
available at "
http://localhost:8080/hellophp/jmaki-core/index.php".
If you look at "index.php" in the IDE, the page contains the following code fragments:
<?php addWidget("hello"); ?>
<?php addWidget( array( "name" => "hello2",
"args" => "{name: 'Duke'}")
); ?>
If you look at the source code of the generated page, the PHP code is converted to JavaScript code as shown below:<link type='text/css' rel='stylesheet' href='http://localhost:8080:8080/hellophp/jmaki-core/resources/hello/component.css'></link>and
<script type='text/javascript' src='http://localhost:8080:8080/hellophp/jmaki-core/resources/hello/component.js'></script>
<script type='text/javascript'>
jmaki.addWidget({uuid:"hello_2",
name:"hello",
widgetDir:"http://localhost:8080:8080/hellophp/jmaki/resources/hello",
script:"http://localhost:8080:8080/hellophp/jmaki/resources/hello/component.js"});
</script>
<link type='text/css' rel='stylesheet' href='http://localhost:8080:8080/hellophp/jmaki-core/resources/hello2/component.css'></link>
<script type='text/javascript' src='http://localhost:8080:8080/hellophp/jmaki-core/resources/hello2/component.js'></script>
<div id="hello2_3" class="hello2"></div>
<script type='text/javascript'>
jmaki.addWidget({uuid:"hello2_3",
name:"hello2",
widgetDir:"http://localhost:8080:8080/hellophp/jmaki-core/resources/hello2",
args: {name: 'Duke'},
script:"http://localhost:8080:8080/hellophp/jmaki-core/resources/hello2/component.js"});
</script>
Notice the JavaScript code shows the host + port as "localhost:8080:8080". This issue is followed here.
- Download and Unzip the contents of
jMaki/PHP release (0.9.7.2 as of this writing). This creates "
- Build, Install and Run a slightly advanced sample.
- Go to "
jmaki-php-0.9.7.2\jmaki-php\samples\loadtable" and invoke "ant". This creates "dist\jmaki-loadtable-php-0.9.7.2.zip". - Unzip the contents of this zip file under the "
web" directory of your project. - Redeploy you project and the sample is now deployed at "
http://localhost:8080/hellophp/web/jmaki-loadtable/index.php".
This sample shows a Dojo DataTable loading static data. The code fragment to add the widget to the page is:
<?php
addWidget('dojo.table', null, null, null, "tabledata.json");
?>
You can look at the generated source using "View Source". A nice twist to try is to dynamically load the data from a database using JPA as shown here.
- Go to "
None of the samples that use XMLHttpProxy (rssData, cl-mashup and mapit) will work because I could not find XSLT extension for Quercus. This issue is followed here. Other users have asked similar question with no clear answer.
Technorati: jmaki php glassfish web2.0 caucho quercus
- Login or register to post comments
- Printer-friendly version
- arungupta's blog
- 1297 reads





