Home DevShare deploying-birt-reports

Calling BIRT From PHP

by JasonW

Posted Feb 26, 2009 (Edited Aug 14, 2009 )

(0 reviews, 9028 views)

This article, published on TheServerSide, and related code, explain how to call BIRT from a PHP application using the open source PHP/Java Bridge.

This WAR contains the open source PHP/Java Bridge and BIRT plugins.  It also has several examples of calling the BIRT Engine, including BIRT Library Usage and Drill Through.

Information on the PHP/Bridge can be found at: http://php-java-bridge.sourceforge.net/pjb/. The PHP/Bridge and docs can also be downloaded from  http://sourceforge.net/project/showfiles.php?group_id=117793

BIRT 2.2.2 is included as part of the 5.4.3.3 documentation download.  The attached war includes BIRT 2.3.1. 

Article explaining the examples contained in the WAR is located at http://www.theserverside.com/tt/articles/article.tss?l=IntegratingBIRTwithPHP

Deploy the WAR and enter the url http://localhost:8080/JavaBridge/index.php to see a list of examples.
Next you can create a directory under you web server that is running PHP and copy all the PHP pages and report designs from the war to this new location.  Also copy the java directory that is contained the JavaBridge.war/java.

for example

htdocs/myphpbirt/java
contains a java directory with all the JavaBridge include files

JDBC Drivers

Use one of the following methods

1 - Place JDBC drivers in the exploded jar

JavaBridge\WEB-INF\platform\plugins\org.eclipse.birt.report.data.oda.jdbc_2.3.1.v20080827\drivers

directory.

2 - change the BirtEngine.java class file in the birtEngine.jar to add the following code:

EngineConfig config = new EngineConfig();

config.getAppContext().put("OdaJDBCDriverClassPath", "locationofdirectorycontainingdrivers");

3- add the following to the PHP examples prior to running a report

$birtReportEngine->getConfig()->getAppContext()->put("OdaJDBCDriverClassPath", $here . "/jdbc/"); and put your drivers in the jdbc directory.

BIRT EventHandlers and extending Classpath

To add event handlers or extend the classpath set the appcontext variable "webapplication.projectclasspath" with full classpath to the jars you need to add.  See JDBC drivers step 2 or 3 to see how to do this.

config.getAppContext().put("webapplication.projectclasspath", "c:/myjars/jar1.jar;c:/myjars/jar2.jar");


If you wish to change the version of BIRT, do the following:

download the BIRT runtime for the version you need.

extract the attached WAR and and replace the WEB-INF/platform/plugins and WEB-INF/platform/config directories with the BIRT runtime download/ReportEngine/plugins and /ReportEngine/configuration directories.  Replace the WEB-INF/lib jars for the specific version of BIRT you are using.  Verify that the WEB-INF/platform/confi directory only contains a config.ini before redeploying the WAR.

Depending on the version of BIRT you use you may need to rebuild the birtEngine.jar which contains the BirtEngine.class.  The source is in the jar.  You may also need to update the examples.

OpenJDK note:  If you are using OpenJDK version 6 or 7 a different version of Rhino is included in the jre/lib directory.  You will either need to remove the jar or replace it with the version BIRT uses. See the following bugzilla entry for the OpenJDK http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=179.

Go to Resource


 
Filter More