PHP code example of davidecaruso / jasper-php

1. Go to this page and download the library: Download davidecaruso/jasper-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

davidecaruso / jasper-php example snippets


$jasper = new JasperPHP;
$jasper->compile('path/to/report.jrxml')->execute();

$jasper = new JasperPHP;
$jasper->process(
    'path/to/report.jasper',
    null,
    ['csv'],
    [],
    [
        'driver' => 'json',
        'json_query' => 'data',
        'data_file' => 'path/to/data.json'
    ]
)->execute();

$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();

$jasper = new JasperPHP('path/to/jasperstarter');
$jasper->compile('path/to/report.jrxml')->execute();
bash
$ composer