Download the PHP package soluble/jasper without Composer
On this page you can find all versions of the php package soluble/jasper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download soluble/jasper
More information about soluble/jasper
Files in soluble/jasper
Package jasper
Short Description Jasper reports in PHP
License MIT
Homepage https://github.com/belgattitude/soluble-jasper
Informations about the package jasper
soluble-jasper
PDF report generation with jasper reports for PHP.
Docs: https://belgattitude.github.io/soluble-jasper
Features
- Report generation in PDF (other formats can be supported, open an issue)
- Datasources for JDBC, JSON and XML (url or filesystem)
- Support for PSR-7 responses (stream)
Requirements
- PHP 7.1+
- PHPJasperBridge (see install)
- Java
Dependencies
- soluble-japha client for communication with the jasper bridge
Examples
Creating a new report
Datasources
Jasper reports supports multiple datasources for filling the report (see JRApi)
JavaSqlConnection
Example using JavaSqlConnection
:
!!! tip
For convenience you can also use the JdbcDsnFactory
to convert
database params.
JsonDataSource
Example using JsonDataSource
:
XmlDataSource
Example using XmlDataSource
:
Logging
You can enable any psr/log
compatible logger. Here's a basic example with monolog:
Exceptions
When running or exporting a report, the following exception can be thrown:
Generally at compile time:
Exception | Description |
---|---|
ReportFileNotFoundException |
When the report file cannot be opened (PHP or Java side, check perms) |
BrokenXMLReportFileException |
When the report JRXML file cannot be parsed (xml error) |
ReportCompileException |
Compilation error, generally an invalid expression or missing resource |
JavaProxiedException |
Exception on the Java side, and call $e->getJvmStackTrace() for debug |
RuntimeException |
Normally never thrown, see exception message |
At filling time:
Exception | Description |
---|---|
BrokenJsonDataSourceException |
When the json datasource cannot be parsed |
JavaProxiedException |
Exception on the Java side, and call $e->getJvmStackTrace() for debug |
Installation
This project requires a java server (or service) running on the same machine that will expose the jasper API to the php side (network bridge).
Check the installation example below or a more complex doc here.
JasperBridge
Build a war file
Deploy on Tomcat (example on ubuntu sudo apt install tomcat8
)
Wait few seconds and point your browser to http://localhost:8080/JasperReports, you should see the php-java-bridge dashboard page.
The bridge address can be used in the japha bridge adapter:
If you encounter permissions problems (i.e. the pdf are created under tomcat8 user), just add your user to the tomcat group:
Benchmarks
Early benchmarks for common operation (run on a laptop for now, will do soon on digitalocean). See tests/bench/simple_benchmarks.php
.
Jasper compile time and filling (internal)
Benchmark name | x1 | x5 | x10 | Average | Memory |
---|---|---|---|---|---|
00_report_mini.jrxml (compile) | 43.03ms | 179.05ms | 347.55ms | 35.60ms | 18.97Kb |
00_report_mini.jrxml (fill) | 3.19ms | 9.15ms | 18.58ms | 1.93ms | 14.27Kb |
01_report_default.jrxml (compile) | 39.24ms | 192.41ms | 338.65ms | 35.64ms | 0.31Kb |
01_report_default.jrxml (fill) | 3.70ms | 11.22ms | 22.75ms | 2.35ms | 0.44Kb |
PDF exports
Benchmark name | x1 | x5 | x10 | Average | Memory |
---|---|---|---|---|---|
00_report_mini.jrxml (text-only) | 38.74ms | 3.76ms | 8.58ms | 3.19ms | 0.79Kb |
01_report_default.jrxml (text+png) | 318.68ms | 1,365.02ms | 2,709.56ms | 274.58ms | 0.75Kb |
06_report_barcodes.jrxml (barcodes) | 123.81ms | 323.71ms | 630.51ms | 67.38ms | 0.75Kb |
- Connection time: 3 ms
Coding standards and interop
All versions of jasper with dependencies
psr/log Version ^1.0
psr/http-message Version ^1.0.1
soluble/japha Version ^2.5.1
zendframework/zend-diactoros Version ^1.6 || ^2.0