Using BIRT with PHP and php/Java bridge

As I promised some days before, here you get the tutorial of how to use BIRT, PHP, Zend Framework (ZF) and php/Java bridge (pJb).

Software requirements
I have tested the environment with:
* Zend Framework 1.0.1
* php/Java bridge 4.3.0
* BIRT 2.2.0
* PHP 5.2.1
* Ecw_Java_* classes version 1.0 (EcwJ)

Installation
I presume, you have already unpacked ZF. Unpack the EcwJ into the ZF library path (/library).
Unpack the directory ReportEngine from the BIRT package to a directory of your choice.
Create a directory called pJb. Extract the directory java from the JavaBridge.war (it is in the pJb package) into it. Extract /WEB-INF/lib/JavaBridge.jar into the /pjb directory.
Create the directories /pjb/lib and /pjb/srv

In the end you should have the following directory structure:


/birt/
/birt/ReportEngine
/pjb/
/pjb/java
/pjb/lib
/pjb/srv
//library/Ecw
//library/Ecw/Java
//library/Ecw/Java/Bridge
//library/Ecw/Java/Reporting
//library/Ecw/Java/Reporting/Birt

Create a batch or bash file /pjb/start-bridge.[bat|sh]. Use this content.

Windows:

java.exe -Duser.home=$DIR_PJBsrv;php.java.bridge.base=$DIR_PJB JavaBridge.jar SERVLET:8080 5 php-java-brige.log

Windows:

#!/bin/bash
java -Duser.home=$DIR_PJB/srv;php.java.bridge.base=$DIR_PJB JavaBridge.jar SERVLET:8080 5 php-java-brige.log

Replace $DIR_PJB with your installation directory of pJb. The argument -Duser.home fixes a security hole version 4.3.0 of pJb contains.

You can now start the pJb with executing start-bridge.[bat|sh].
php-java-bridge.log should contain something like this:

Sep 23 19:57:40 JavaBridge INFO : VM                  : 1.6.0_02@http://java.sun.com/
Sep 23 19:57:40 JavaBridge INFO : JavaBridge version             : 4.2.2
Sep 23 19:57:40 JavaBridge INFO : logFile             : php-java-brige.log
Sep 23 19:57:40 JavaBridge INFO : default logLevel    : 5
Sep 23 19:57:40 JavaBridge INFO : socket              : SERVLET:8080
Sep 23 19:57:40 JavaBridge INFO : java.ext.dirs       : C:ckldevlangjavadistjre1.6.0_02libext;C:WINDOWSSunJavalibext
Sep 23 19:57:40 JavaBridge INFO : php.java.bridge.base: C:ckldevprojectsweb200_VwpilotPRtrunkbinphp-java-bridgesrv;php.java.bridge.base=C:ckldevprojectsweb200_VwpilotPRtrunkbinphp-java-bridge
Sep 23 19:57:40 JavaBridge INFO : extra library dir   : C:ckldevprojectsweb200_VwpilotPRtrunkbinphp-java-bridgesrv;php.java.bridge.base=C:ckldevprojectsweb200_VwpilotPRtrunkbinphp-java-bridgelib
Sep 23 19:57:40 JavaBridge INFO : thread pool size    : 20
Sep 23 19:57:40 JavaBridge INFO : JavaBridgeRunner started on port INET:8080
...

Set the environment variable BIRT_HOME to the direcoty of your ReportEngine.

Windows:

set BIRT_HOME=$DIR_BIRT/ReportEngine

Linux

export BIRT_HOME=$DIR_BIRT/ReportEngine

Replace $DIR_BIRT with your installation path of BIRT.

First steps in PHP
Copy the following content to a ZF controller of your choice:

Ecw_Java_Bridge_Instance::setServerUrl("$SERVER_URL");
            Ecw_Java_Bridge_Instance::getInstance();
java_set_file_encoding("UTF-8");
Ecw_Java_Bridge_Instance::java_require_dir("$DIR_RE/lib");

$report = new Ecw_Java_Reporting_Birt_Pdf("$DIR_RE");
$report->setReportPath("$DIR_RE/samples/hello_world.rptdesign");
$report->setOutputFileName("$DIR_RE/samples/hello_world.pdf");
            $report->run();

Replace $SERVER_URL with the address of pJb instance. This should be http://localhost:8080/JavaBridge/java/Java.inc.
Replace $DIR_RE with the BIRT ReportEngine directory.

Execute the controller in your browser and you should see a hello_world.pdf in $DIR_BIRT/samples directory.

Comments ( 2 )

  1. / ReplyRoger Hunwicks
    Thank you for these posts, they are very interesting. I have just started looking at using the php-java bridge as an alternative to Zend Platform for running BIRT reports on PHP. Would you be happy to share your ecw_java classes? Are they available for download anywhere? Thanks, Roger
  2. / ReplyAnonymous
    Hello Roger, I have published the wrapper classes under [url]http://wap.ecw.de/modules/blog/?action=show&id=425[/url]. Christopher

Leave a reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>