PHPackages                             jheferson-br/phpjasper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. jheferson-br/phpjasper

ActiveLibrary

jheferson-br/phpjasper
======================

A simplified, easy-to-implement PHP report generator

4.0.6(3y ago)01442MITPHP

Since Sep 28Pushed 3y agoCompare

[ Source](https://github.com/JhefersonBR/phpjasper)[ Packagist](https://packagist.org/packages/jheferson-br/phpjasper)[ RSS](/packages/jheferson-br-phpjasper/feed)WikiDiscussions master Synced today

READMEChangelog (5)DependenciesVersions (6)Used By (0)

PHPJasper
=========

[](#phpjasper)

*A simplified, easy-to-implement PHP report generator*

### About

[](#about)

PHPJasper is the best solution to compile and process JasperReports (.jrxml &amp; .jasper files) just using PHP, in short: to generate reports using PHP.

Installation
------------

[](#installation)

Install [Composer](http://getcomposer.org) if you don't have it.

```
composer require jheferson-br/phpjasper

```

Or in your file'composer.json' add:

```
{
    "require": {
        "jheferson-br/phpjasper": "^3.2.7"
    }
}
```

And the just run:

```
composer install

```

and thats it.

---

Examples
--------

[](#examples)

#### Compiling

[](#compiling)

First we need to compile our `JRXML` file into a `JASPER` binary file. We just have to do this one time.

**Note 1:** You don't need to do this step if you are using *Jaspersoft Studio*. You can compile directly within the program.

```
require __DIR__ . '/vendor/autoload.php';

$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/hello_world.jrxml';

$jasper = new PHPJasper;
$jasper->compile($input)->execute();
```

This commando will compile the `hello_world.jrxml` source file to a `hello_world.jasper` file.

#### Processing

[](#processing)

Now lets process the report that we compile before:

```
require __DIR__ . '/vendor/autoload.php';

$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/hello_world.jasper';
$output = __DIR__ . '/vendor/geekcom/phpjasper/examples';
$options = [
    'format' => ['pdf', 'rtf']
];

$jasper = new PHPJasper;

$jasper->process(
    $input,
    $output,
    $options
)->execute();
```

Now check the examples folder! :) Great right? You now have 2 files, `hello_world.pdf` and `hello_world.rtf`.

Check the *methods* `compile` and `process` in `src/JasperPHP.php` for more details

#### Listing Parameters

[](#listing-parameters)

Querying the jasper file to examine parameters available in the given jasper report file:

```
require __DIR__ . '/vendor/autoload.php';

$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/hello_world_params.jrxml';

$jasper = new PHPJasper;
$output = $jasper->listParameters($input)->execute();

foreach($output as $parameter_description)
    print $parameter_description . '';
```

### Using database to generate reports

[](#using-database-to-generate-reports)

We can also specify parameters for connecting to database:

```
require __DIR__ . '/vendor/autoload.php';

$input = '/your_input_path/your_report.jasper';
$output = '/your_output_path';
$options = [
    'format' => ['pdf'],
    'locale' => 'en',
    'params' => [],
    'db_connection' => [
        'driver' => 'postgres', //mysql, ....
        'username' => 'DB_USERNAME',
        'password' => 'DB_PASSWORD',
        'host' => 'DB_HOST',
        'database' => 'DB_DATABASE',
        'port' => '5432'
    ]
];

$jasper = new PHPJasper;

$jasper->process(
        $input,
        $output,
        $options
)->execute();
```

**Note 2:**

For a complete list of locales see [Supported Locales](http://www.oracle.com/technetwork/java/javase/java8locales-2095355.html)

### Using MSSQL DataBase

[](#using-mssql-database)

```
require __DIR__ . '/vendor/autoload.php';

$input = '/your_input_path/your_report.jasper or .jrxml';
$output = '/your_output_path';
$jdbc_dir = __DIR__ . '/vendor/geekcom/phpjasper/bin/jaspertarter/jdbc';
$options = [
    'format' => ['pdf'],
    'locale' => 'en',
    'params' => [],
    'db_connection' => [
        'driver' => 'generic',
        'host' => '127.0.0.1',
        'port' => '1433',
        'database' => 'DataBaseName',
        'username' => 'UserName',
        'password' => 'password',
        'jdbc_driver' => 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
        'jdbc_url' => 'jdbc:sqlserver://127.0.0.1:1433;databaseName=Teste',
        'jdbc_dir' => $jdbc_dir
    ]
];

$jasper = new PHPJasper;

$jasper->process(
        $input,
        $output,
        $options
    )->execute();
```

### Reports from a XML

[](#reports-from-a-xml)

```
require __DIR__ . '/vendor/autoload.php';

$input = '/your_input_path/your_report.jasper';
$output = '/your_output_path';
$data_file = __DIR__ . '/your_data_files_path/your_xml_file.xml';
$options = [
    'format' => ['pdf'],
    'params' => [],
    'locale' => 'en',
    'db_connection' => [
        'driver' => 'xml',
        'data_file' => $data_file,
        'xml_xpath' => '/your_xml_xpath'
    ]
];

$jasper = new PHPJasper;

$jasper->process(
    $input,
    $output,
    $options
)->execute();
```

### Reports from a JSON

[](#reports-from-a-json)

```
require __DIR__ . '/vendor/autoload.php';

$input = '/your_input_path/your_report.jasper';
$output = '/your_output_path';

$data_file = __DIR__ . '/your_data_files_path/your_json_file.json';
$options = [
    'format' => ['pdf'],
    'params' => [],
    'locale' => 'en',
    'db_connection' => [
        'driver' => 'json',
        'data_file' => $data_file,
        'json_query' => 'your_json_query'
    ]
];

$jasper = new PHPJasper;

$jasper->process(
    $input,
    $output,
    $options
)->execute();
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 65.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~63 days

Total

5

Last Release

1434d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a7ca938fab2b2a4751c1511efd8b749ebba0408ac17460ddc84072a2a3614a56?d=identicon)[Jheferson](/maintainers/Jheferson)

---

Top Contributors

[![geekcom](https://avatars.githubusercontent.com/u/3955933?v=4)](https://github.com/geekcom "geekcom (244 commits)")[![allcontributors[bot]](https://avatars.githubusercontent.com/in/23186?v=4)](https://github.com/allcontributors[bot] "allcontributors[bot] (48 commits)")[![rafaelqueiroz](https://avatars.githubusercontent.com/u/275919?v=4)](https://github.com/rafaelqueiroz "rafaelqueiroz (19 commits)")[![JhefersonBR](https://avatars.githubusercontent.com/u/25249696?v=4)](https://github.com/JhefersonBR "JhefersonBR (17 commits)")[![lavela](https://avatars.githubusercontent.com/u/13982234?v=4)](https://github.com/lavela "lavela (15 commits)")[![leandrocopam](https://avatars.githubusercontent.com/u/33423387?v=4)](https://github.com/leandrocopam "leandrocopam (8 commits)")[![ThiagoAlves31](https://avatars.githubusercontent.com/u/32931011?v=4)](https://github.com/ThiagoAlves31 "ThiagoAlves31 (5 commits)")[![dbould](https://avatars.githubusercontent.com/u/5477476?v=4)](https://github.com/dbould "dbould (5 commits)")[![jadsonbr](https://avatars.githubusercontent.com/u/10354607?v=4)](https://github.com/jadsonbr "jadsonbr (2 commits)")[![boaglio](https://avatars.githubusercontent.com/u/6140?v=4)](https://github.com/boaglio "boaglio (2 commits)")[![xRahul](https://avatars.githubusercontent.com/u/1639945?v=4)](https://github.com/xRahul "xRahul (1 commits)")[![allenjd3](https://avatars.githubusercontent.com/u/8092154?v=4)](https://github.com/allenjd3 "allenjd3 (1 commits)")[![davidribeiro](https://avatars.githubusercontent.com/u/11426456?v=4)](https://github.com/davidribeiro "davidribeiro (1 commits)")[![jrskill](https://avatars.githubusercontent.com/u/106967363?v=4)](https://github.com/jrskill "jrskill (1 commits)")[![lecneri](https://avatars.githubusercontent.com/u/431453?v=4)](https://github.com/lecneri "lecneri (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![vitormattos](https://avatars.githubusercontent.com/u/1079143?v=4)](https://github.com/vitormattos "vitormattos (1 commits)")

### Embed Badge

![Health badge](/badges/jheferson-br-phpjasper/health.svg)

```
[![Health](https://phpackages.com/badges/jheferson-br-phpjasper/health.svg)](https://phpackages.com/packages/jheferson-br-phpjasper)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
