davidecaruso / jasper-php
PHP library to execute Jasper Reports
Installs: 215
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Language:HTML
pkg:composer/davidecaruso/jasper-php
Requires
- php: >=7.0.0
Requires (Dev)
- codeception/aspect-mock: ^2.1
- codeception/codeception: ^2.3
This package is auto-updated.
Last update: 2025-10-26 07:47:51 UTC
README
PHP library to generate Jasper Reports.
Install
$ composer require davidecaruso/jasper-php
This automatically installs and provides the Jasper Starter executable and the MySQL Connector Driver. You can also pass to the library's constructor your jasperstarter file's path.
Requirements
- PHP >= 7.0
- Java >= 1.8.0
- Jasper Starter (automatically provided by the Composer installation)
Usage
Compile a jrxml file into a jasper file:
$jasper = new JasperPHP; $jasper->compile('path/to/report.jrxml')->execute();
Generate report via JSON connection:
$jasper = new JasperPHP; $jasper->process( 'path/to/report.jasper', null, ['csv'], [], [ 'driver' => 'json', 'json_query' => 'data', 'data_file' => 'path/to/data.json' ] )->execute();
Example of data.json file:
{
"data": [
{
"first-name": "Foo",
"last-name": "Bar",
"age": 32
},
{
"first-name": "Baz",
"last-name": "Foobar",
"age": 16
}
]
}
Generate report via MySQL connection:
$jasper = new JasperPHP; $jasper->process( 'path/to/report.jasper', false, array('xlsx'), array(), array( 'driver' => 'mysql', 'username' => 'root', 'password' => 'root', 'host' => 'localhost', 'database' => 'mydatabase', 'port' => '3306', ) )->execute();
Use an own executable Jasper Starter file:
$jasper = new JasperPHP('path/to/jasperstarter'); $jasper->compile('path/to/report.jrxml')->execute();
Author
License
Licensed under MIT.