|
1 |
| -# JasperReports for PHP v1.0 |
| 1 | +# JasperReports for PHP and Laravel Framework |
2 | 2 |
|
3 | 3 | [](https://packagist.org/packages/lavela/phpjasper) [](https://packagist.org/packages/lavela/phpjasper) [](https://packagist.org/packages/lavela/phpjasper) [](https://packagist.org/packages/lavela/phpjasper)
|
4 | 4 |
|
@@ -161,7 +161,7 @@ foreach($output as $parameter_description)
|
161 | 161 | print $parameter_description . '<pre>';
|
162 | 162 | ```
|
163 | 163 |
|
164 |
| -###Advanced example |
| 164 | +###Advanced example - using a database |
165 | 165 |
|
166 | 166 | We can also specify parameters for connecting to database:
|
167 | 167 |
|
@@ -190,7 +190,6 @@ $jasper->process(
|
190 | 190 | )->execute();
|
191 | 191 | ```
|
192 | 192 |
|
193 |
| - |
194 | 193 | ###Using JasperPHP with Laravel 5.2!
|
195 | 194 |
|
196 | 195 | 1. Install [Composer](http://getcomposer.org) if you don't have it.
|
@@ -245,6 +244,57 @@ Route::get('/reports', function () {
|
245 | 244 | In this example we generate reports pdf, rtf and xml.
|
246 | 245 |
|
247 | 246 |
|
| 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 | + |
248 | 298 | ###MySQL
|
249 | 299 |
|
250 | 300 | We ship the [MySQL connector](http://dev.mysql.com/downloads/connector/j/) (v5.1.34) in the `/src/JasperStarter/jdbc/` directory.
|
|
0 commit comments