sergio-vilchis/laravel-phpjasperxml

Laravel package to render JasperReports
3,172 2
Install
composer require sergio-vilchis/laravel-phpjasperxml
Latest Version:1.3.0
Last Updated:Oct 13, 2016
Links: GitHub  ·  Packagist
Maintainer: sergio-vilchis

laravel-phpjasperxml

A Laravel package to render JasperReports.

###Installation

Add the following lines to your composer.json file

...
  sergio-vilchis/laravel-phpjasperxml": "^1.0"
}

Then update your packages with:

composer update

Add the Service Provider to you config/app.php file

'providers' => [
  ...
  Sergio\PhpJasperXML\JasperReportsServiceProvider::class,
]

And add an alias to the PHPJasperXML class

'aliases' => [
  ...
  'PHPJasperXML'  => Sergio\PhpJasperXML\PHPJasperXML::class,
]

Create an includes folder on your app and save there your jrxml files.

Create a ReportController with the following code

<?php
namespace App\Http\Controllers;
use PHPJasperXML;
use Response;
class ReportController extends Controller {

    public function viewreport($reporte='')
    {
      $PHPJasperXML = new PHPJasperXML();
      $PHPJasperXML->load_xml_file(app_path()."/includes/reports/".$reporte.".jrxml");
      $PHPJasperXML->transferDBtoArray();
      //Clean the end of the buffer before outputting the PDF
      ob_end_clean();
      //page output method I:standard output  D:Download file
      return Response::make($PHPJasperXML->outpage("I"));
    }

}

Then modify your app/Http/routes.php file to add a route to access any report.

Route::get('report/{report}', 'ReportController@viewreport')->name('report.show');

Related Packages

erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

628,058,007 9,707
laravel/framework

The Laravel Framework.

576,155,700 34,907
laravel/tinker

Powerful REPL for the Laravel framework.

485,678,092 7,440