https://github.com/davidecaruso/jasper-php
📊 PHP library to execute Jasper Reports
https://github.com/davidecaruso/jasper-php
composer-package jasper-reports jasperphp jasperreports php php-library
Last synced: about 2 months ago
JSON representation
📊 PHP library to execute Jasper Reports
- Host: GitHub
- URL: https://github.com/davidecaruso/jasper-php
- Owner: davidecaruso
- License: mit
- Created: 2018-02-05T14:06:28.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-03-16T21:35:19.000Z (about 7 years ago)
- Last Synced: 2025-03-08T09:46:59.920Z (3 months ago)
- Topics: composer-package, jasper-reports, jasperphp, jasperreports, php, php-library
- Language: HTML
- Homepage:
- Size: 75.8 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jasper PHP
PHP library to generate Jasper Reports.
## Install
```bash
$ composer require davidecaruso/jasper-php
```
This automatically installs and provides the [Jasper Starter](http://jasperstarter.cenote.de/) executable and the [MySQL Connector Driver](https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-installing.html). 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:
```php
$jasper = new JasperPHP;
$jasper->compile('path/to/report.jrxml')->execute();
```### Generate report via JSON connection:
```php
$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:
```json
{
"data": [
{
"first-name": "Foo",
"last-name": "Bar",
"age": 32
},
{
"first-name": "Baz",
"last-name": "Foobar",
"age": 16
}
]
}
```### Generate report via MySQL connection:
```php
$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:
```php
$jasper = new JasperPHP('path/to/jasperstarter');
$jasper->compile('path/to/report.jrxml')->execute();
```## Author
[Davide Caruso](https://davidecaruso.github.io)## License
Licensed under [MIT](https://opensource.org/licenses/mit-license.php).