Using Jasper Reports on a PHP Website

I would like to use the Java report reporting engine to create reports (HTML / PDF, etc.) and display them on my website.

However, my site uses the PHP web framework. Can anyone suggest how I can use Jasper Reports in a PHP web environment?

+4
source share
3 answers

If you test the REST PHP client on Github or add it to your PHP project through Composer, you can run the report through web services.

Your code should look something like this:

<?php $c = new \Jaspersoft\Client\Client( "http://localhost:8080/jasperserver-pro", "jasperadmin", "jasperadmin", "organization_1" ); $report = $c->reportService()->runReport('/reports/samples/AllAccounts', 'html'); echo $report; ?> 

This will get the report in HTML format and save it in $report . Of course, you can change html to pdf or xls or any other format you want to export.

If you want to display PDF files or offer them for download, you will need to provide the binary data in some kind of package that can process it, or provide the proper headers to load the web browser.

I happen to be the one who develops this package, so feel free to take pictures of me with any questions.

+7
source
  • using PHP / Java Bridge (http://php-java-bridge.sourceforge.net/).
  • Deploying the Java bridge on the tomcat server.
  • copy jar jasper lib and mysql connector j lib to tomcat lib
  • restart tomcat server
  • edit php.ini (allow_url_include = On)
  • include library path in php file. try referring to this code for more information .. http://github.com/tsuyu/jasper-report-php-integration
+3
source

You will need to either build / find the java interpreter in php. Or more realistic, ask Java from PHP using Exec ()

EDIT

Or exchange a database connection and create a table for interconnection. Which has good scalability points in its favor.

0
source

All Articles