PHPackages                             chrmorandi/yii2-jasper - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. chrmorandi/yii2-jasper

AbandonedYii2-extension[PDF &amp; Document Generation](/categories/documents)

chrmorandi/yii2-jasper
======================

Create Reports in PHP with JasperReports

v1.1.1(7y ago)1110.4k↓100%8MITHTMLPHP &gt;=5.4.0

Since May 5Pushed 6y ago4 watchersCompare

[ Source](https://github.com/chrmorandi/yii2-jasper)[ Packagist](https://packagist.org/packages/chrmorandi/yii2-jasper)[ Docs](https://github.com/chrmorandi/yii2-jasper)[ RSS](/packages/chrmorandi-yii2-jasper/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (3)Versions (7)Used By (0)

JasperReports for PHP
=====================

[](#jasperreports-for-php)

[![Latest Stable Version](https://camo.githubusercontent.com/52161f608e9dbe5f27caad101ac9019acab60be18fa23e74a13a65b50fc95f52/68747470733a2f2f706f7365722e707567782e6f72672f6368726d6f72616e64692f796969322d6a61737065722f762f737461626c65)](https://packagist.org/packages/chrmorandi/yii2-jasper)[![Total Downloads](https://camo.githubusercontent.com/92b46c2e9d6e2ecaf639970addbedcf2d68d4095fbecae6c160548523b3b6eeb/68747470733a2f2f706f7365722e707567782e6f72672f6368726d6f72616e64692f796969322d6a61737065722f646f776e6c6f616473)](https://packagist.org/packages/chrmorandi/yii2-jasper)[![License](https://camo.githubusercontent.com/341d7fd34b5202595cc03840d64ce362882b80af03a37a8596c399413864b369/68747470733a2f2f706f7365722e707567782e6f72672f6368726d6f72616e64692f796969322d6a61737065722f6c6963656e7365)](https://packagist.org/packages/chrmorandi/yii2-jasper)[![Build Status](https://camo.githubusercontent.com/ac57931b3aa7ce9377d2348d61d6a9da174b3af945db62de8c95426d7766abda/68747470733a2f2f7472617669732d63692e6f72672f6368726d6f72616e64692f796969322d6a61737065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/chrmorandi/yii2-jasper)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/938420a52a7a72b534eb629a17fcbfe4e12bdad7089c535e7204c8b9e675f008/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6368726d6f72616e64692f796969322d6a61737065722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/chrmorandi/yii2-jasper/?branch=master)

Package to generate reports with [JasperReports 6](http://community.jaspersoft.com/project/jasperreports-library) library through [JasperStarter v3](http://jasperstarter.sourceforge.net/) command-line tool.

\##Install

```
composer require chrmorandi/jasper
```

\##Introduction

This package aims to be a solution to compile and process JasperReports (.jrxml &amp; .jasper files).

\###Why?

**JasperReports** is the best open source solution for reporting.

Generating HTML + CSS to make a PDF. Never think about it, that doesn't make any sense! :p

\###What can I do with this?

Well, everything. JasperReports is a powerful tool for **reporting** and **BI**.

**From their website:**

> The JasperReports Library is the world's most popular open source reporting engine. It is entirely written in Java and it is able to use data coming from any kind of data source and produce pixel-perfect documents that can be viewed, printed or exported in a variety of document formats including HTML, PDF, Excel, OpenOffice and Word.

I recommend using [Jaspersoft Studio](http://community.jaspersoft.com/project/jaspersoft-studio) to build your reports, connect it to your datasource (ex: MySQL), loop thru the results and output it to PDF, XLS, DOC, RTF, ODF, etc.

*What you can do with Jaspersoft:*

- Graphical design environment
- Pixel-perfect report generation
- Output to PDF, HTML, CSV, XLS, TXT, RTF and more

\##Examples

\###The *Hello World* example.

Go to the examples directory in the root of the repository (`vendor/chrmorandi/yii2-jasper/examples`). Open the `hello_world.jrxml` file with iReport or with your favorite text editor and take a look at the source code.

\##Requirements

- Java JDK 8 or higher
- PHP [exec()](http://php.net/manual/function.exec.php) function
- \[optional\] [Mysql Connector](http://dev.mysql.com/downloads/connector/j/) (if you want to use Mysql database)
- \[optional\] [PostgreSQL Connector](https://jdbc.postgresql.org/download.html) (if you want to use PostgreSQL database)
- \[optional\] [Jaspersoft Studio](http://community.jaspersoft.com/project/jaspersoft-studio) (to draw and compile your reports)

\##Installation

\###Java

Check if you already have Java installed:

```
$ java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
```

If you get:

```
command not found: java

```

Then install it with: (Ubuntu/Debian)

```
    $ sudo apt-get install default-jdk
```

Now run the `java -version` again and check if the output is ok.

\###Composer

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

```
composer require chrmorandi/yii2-jasper
```

Or in your `composer.json` file add:

```
{
    "require": {
        "chrmorandi/yii2-jasper": "*"
    }
}
```

And the just run:

```
composer update
```

and thats it.

\###Add the component to the configuration

Use Data Source Name (DSN) for connection information with the database in format like Driver invocation. See [http://php.net/manual/pt\_BR/pdo.construct.php](http://php.net/manual/pt_BR/pdo.construct.php)

```
return [
    ...
    'components'          => [
        'jasper' => [
            'class' => 'chrmorandi\jasper\Jasper::className()',
            'redirect_output' => false, //optional
            'resource_directory' => false, //optional
            'locale' => 'pt_BR', //optional
            'db' => [
                'dsn' =>'psql:host=localhost;port=5432;dbname=myDatabase',
                'username' => 'username',
                'password' => 'password',
                //'jdbcDir' => './jdbc', **Defaults to ./jdbc
                //'jdbcUrl' => 'jdbc:postgresql://"+host+":"+port+"/"+dbname',
            ]
        ]
        ...
    ],
    ...
];
```

\###Using

```
use chrmorandi\jasper\Jasper;

public function actionIndex()
{
    // Set alias for sample directory
    Yii::setAlias('example', '@vendor/chrmorandi/yii2-jasper/examples');

    /* @var $jasper Jasper */
    $jasper = Yii::$app->jasper;

    // Compile a JRXML to Jasper
    $jasper->compile(Yii::getAlias('@example') . '/hello_world.jrxml')->execute();

    // Process a Jasper file to PDF and RTF (you can use directly the .jrxml)
    $jasper->process(
        Yii::getAlias('@example') . '/hello_world.jasper',
        ['php_version' => 'xxx'],
        ['pdf', 'rtf'],
        false,
        false
    )->execute();

    // List the parameters from a Jasper file.
    $array = $jasper->listParameters(Yii::getAlias('@example') . '/hello_world.jasper')->execute();

    // return pdf file
    Yii::$app->response->sendFile(Yii::getAlias('@example') . '/hello_world.pdf');

}
```

\###MySQL

We ship the [MySQL connector](http://dev.mysql.com/downloads/connector/j/) (v5.1.39) in the `/src/JasperStarter/jdbc/` directory.

\###PostgreSQL

We ship the [PostgreSQL](https://jdbc.postgresql.org/) (v9.4-1208) in the `/src/JasperStarter/jdbc/` directory.

\##Performance

Depends on the complexity, amount of data and the resources of your machine.

Is possible generate reports in the background.

\##License

MIT

###  Health Score

35

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 55.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 ~156 days

Recently: every ~192 days

Total

6

Last Release

2828d ago

Major Versions

v0.8.0 → V1.0.02017-08-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/24099a2c0e8c70ceaf9ab51bf461fc8c5070de5067d2844ec2063b96c96582bc?d=identicon)[chrmorandi](/maintainers/chrmorandi)

---

Top Contributors

[![chrmmota](https://avatars.githubusercontent.com/u/242634898?v=4)](https://github.com/chrmmota "chrmmota (40 commits)")[![cossou](https://avatars.githubusercontent.com/u/1337112?v=4)](https://github.com/cossou "cossou (21 commits)")[![attrox](https://avatars.githubusercontent.com/u/3422486?v=4)](https://github.com/attrox "attrox (4 commits)")[![lucassch](https://avatars.githubusercontent.com/u/4160094?v=4)](https://github.com/lucassch "lucassch (3 commits)")[![adrianoleiterodrigues](https://avatars.githubusercontent.com/u/9268559?v=4)](https://github.com/adrianoleiterodrigues "adrianoleiterodrigues (2 commits)")[![chrmorandi](https://avatars.githubusercontent.com/u/11622005?v=4)](https://github.com/chrmorandi "chrmorandi (2 commits)")

---

Tags

phpyii2reportsjasperreportsjavajasperyiiframeworkireport

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/chrmorandi-yii2-jasper/health.svg)

```
[![Health](https://phpackages.com/badges/chrmorandi-yii2-jasper/health.svg)](https://phpackages.com/packages/chrmorandi-yii2-jasper)
```

###  Alternatives

[robregonm/yii2-pdf

Yii 2 PDF Response Formatter

4647.3k1](/packages/robregonm-yii2-pdf)[yii2assets/yii2-pdfjs

Yii2 Extension pdf.js Portable Document Format (PDF) viewer

24207.4k](/packages/yii2assets-yii2-pdfjs)[soluble/jasper

Jasper reports in PHP

111.1k](/packages/soluble-jasper)[codemix/yii2-excel-message

Translate new messages via excel files

125.0k](/packages/codemix-yii2-excel-message)

PHPackages © 2026

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