Skip to content

Commit 9db7b1a

Browse files
committed
Merge branch 'master' of https://github.com/lavela/phpjasper
2 parents deedad7 + df919d8 commit 9db7b1a

File tree

1 file changed

+53
-3
lines changed

1 file changed

+53
-3
lines changed

README.md

+53-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# JasperReports for PHP v1.0
1+
# JasperReports for PHP and Laravel Framework
22

33
[![Latest Stable Version](https://poser.pugx.org/lavela/phpjasper/v/stable)](https://packagist.org/packages/lavela/phpjasper) [![Latest Unstable Version](https://poser.pugx.org/lavela/phpjasper/v/unstable)](https://packagist.org/packages/lavela/phpjasper) [![License](https://poser.pugx.org/lavela/phpjasper/license)](https://packagist.org/packages/lavela/phpjasper) [![Total Downloads](https://poser.pugx.org/lavela/phpjasper/downloads)](https://packagist.org/packages/lavela/phpjasper)
44

@@ -161,7 +161,7 @@ foreach($output as $parameter_description)
161161
print $parameter_description . '<pre>';
162162
```
163163

164-
###Advanced example
164+
###Advanced example - using a database
165165

166166
We can also specify parameters for connecting to database:
167167

@@ -190,7 +190,6 @@ $jasper->process(
190190
)->execute();
191191
```
192192

193-
194193
###Using JasperPHP with Laravel 5.2!
195194

196195
1. Install [Composer](http://getcomposer.org) if you don't have it.
@@ -245,6 +244,57 @@ Route::get('/reports', function () {
245244
In this example we generate reports pdf, rtf and xml.
246245

247246

247+
###Additional Information - Reports from a xml in Laravel 5.2
248+
249+
See how easy it is to generate a report with a source an xml file:
250+
251+
```php
252+
253+
use JasperPHP\JasperPHP;
254+
255+
public function xmlToPdf()
256+
{
257+
$output = public_path() . '/report/'.time().'_CancelAck';
258+
$output = public_path() . '/report/'.time().'_CancelAck';
259+
$ext = "pdf";
260+
$data_file = public_path() . '/report/CancelAck.xml';
261+
$driver = 'xml';
262+
$xml_xpath = '/CancelResponse/CancelResult/ID';
263+
264+
\JasperPHP::process(
265+
public_path() . '/report/CancelAck.jrxml',
266+
$output,
267+
array($ext),
268+
array(),
269+
array('data_file' => $data_file, 'driver' => $driver, 'xml_xpath' => $xml_xpath),
270+
false,
271+
false
272+
)->execute();
273+
274+
header('Content-Description: File Transfer');
275+
header('Content-Type: application/octet-stream');
276+
header('Content-Disposition: attachment; filename='.time().'_CancelAck.'.$ext);
277+
header('Content-Transfer-Encoding: binary');
278+
header('Expires: 0');
279+
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
280+
header('Content-Length: ' . filesize($output.'.'.$ext));
281+
flush();
282+
readfile($output.'.'.$ext);
283+
unlink($output.'.'.$ext);
284+
285+
}
286+
```
287+
**Note:**
288+
289+
To use the example above you must copy the sample files located at:
290+
291+
**\vendor\lavela\phpjasper\src\JasperStarter\examples\CancelAck.jrxml**
292+
and
293+
**\vendor\lavela\phpjasper\src\JasperStarter\examples\CancelAck.xml**
294+
to folder:
295+
**\public\report**
296+
297+
248298
###MySQL
249299

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

0 commit comments

Comments
 (0)