9
9
10
10
###Docs
11
11
[ ![ Language-pt_BR] ( https://img.shields.io/badge/pt__BR-100%25-green.svg )] ( https://github.com/geekcom/phpjasper/blob/master/docs/pt_BR/LEIA-ME_pt_BR.md )
12
- [ ![ Language-de_DE] ( https://img.shields.io/badge/de__DE-10%25-red.svg )] ( https://github.com/geekcom/phpjasper/blob/master/docs/de_DE/LESEN-MICH.md )
13
-
14
12
15
13
###About
16
-
17
14
This package is the solution to compile and process JasperReports (.jrxml & .jasper files) just using PHP.
18
15
16
+ ** Note:** PHPJasper Can be used regardless of your PHP Framework
17
+
19
18
** Note for Linux servers?**
20
19
21
20
Do not forget to grant permission 777 for the directory
@@ -153,16 +152,16 @@ use JasperPHP\JasperPHP;
153
152
154
153
$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/hello_world.jasper';
155
154
$output = __DIR__ . '/vendor/geekcom/phpjasper/examples';
155
+ $options = [
156
+ 'format' => ['pdf', 'rtf']
157
+ ];
156
158
157
159
$jasper = new JasperPHP;
158
160
159
161
$jasper->process(
160
- $input, //input
161
- $output, //output
162
- ['pdf', 'rtf'], //formats
163
- [], //parameters
164
- [], //data_source
165
- 'en' //locale
162
+ $input,
163
+ $output,
164
+ $options
166
165
)->execute();
167
166
```
168
167
@@ -200,26 +199,27 @@ use JasperPHP\JasperPHP;
200
199
201
200
$input = '/your_input_path/your_report.jasper';
202
201
$output = '/your_output_path';
203
- $format = 'pdf';
204
- $locale = 'en';
202
+ $options = [
203
+ 'format' => ['pdf'],
204
+ 'locale' => 'en',
205
+ 'params' => [],
206
+ 'db_connection' => [
207
+ 'driver' => 'postgres',
208
+ 'username' => 'DB_USERNAME',
209
+ 'password' => 'DB_PASSWORD',
210
+ 'host' => 'DB_HOST',
211
+ 'database' => 'DB_DATABASE',
212
+ 'schema' => 'DB_SCHEMA',
213
+ 'port' => '5432'
214
+ ]
215
+ ];
205
216
206
217
$jasper = new JasperPHP;
207
218
208
219
$jasper->process(
209
220
$input,
210
221
$output,
211
- $format,
212
- [], //parameters
213
- [
214
- 'driver' => 'postgres',
215
- 'username' => 'DB_USERNAME',
216
- 'password' => 'DB_PASSWORD',
217
- 'host' => 'DB_HOST',
218
- 'database' => 'DB_DATABASE',
219
- 'schema' => 'DB_SCHEMA',
220
- 'port' => '5432'
221
- ],
222
- $locale
222
+ $options
223
223
)->execute();
224
224
```
225
225
@@ -230,37 +230,36 @@ For a complete list of locales see [Supported Locales](http://www.oracle.com/tec
230
230
###Using MSSQL DataBase
231
231
232
232
``` php
233
-
234
233
require __DIR__ . '/vendor/autoload.php';
235
234
236
235
use JasperPHP\JasperPHP;
237
236
238
237
$input = '/your_input_path/your_report.jasper or .jrxml';
239
238
$output = '/your_output_path';
240
- $format = 'pdf';
241
- $locale = 'en';
242
-
243
- $jdbc_dir = __DIR__ . '/vendor/geekcom/phpjasper/src/JasperStarter/jdbc/';
239
+ $jdbc_dir = __DIR__ . '/vendor/geekcom/phpjasper/bin/jaspertarter/jdbc';
240
+ $options = [
241
+ 'format' => ['pdf'],
242
+ 'locale' => 'en',
243
+ 'params' => [],
244
+ 'db_connection' => [
245
+ 'driver' => 'generic',
246
+ 'host' => '127.0.0.1',
247
+ 'port' => '1433',
248
+ 'database' => 'DataBaseName',
249
+ 'username' => 'UserName',
250
+ 'password' => 'password',
251
+ 'jdbc_driver' => 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
252
+ 'jdbc_url' => 'jdbc:sqlserver://127.0.0.1:1433;databaseName=Teste',
253
+ 'jdbc_dir' => $jdbc_dir
254
+ ]
255
+ ];
244
256
245
257
$jasper = new JasperPHP;
246
258
247
259
$jasper->process(
248
260
$input,
249
261
$output,
250
- $format,
251
- [], //parameters
252
- [
253
- 'driver' => 'generic',
254
- 'host' => '127.0.0.1',
255
- 'port' => '1433',
256
- 'database' => 'DataBaseName',
257
- 'username' => 'UserName',
258
- 'password' => 'password',
259
- 'jdbc_driver' => 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
260
- 'jdbc_url' => 'jdbc:sqlserver://127.0.0.1:1433;databaseName=Teste',
261
- 'jdbc_dir' => $jdbc_dir
262
- ],
263
- $locale
262
+ $options
264
263
)->execute();
265
264
```
266
265
@@ -307,10 +306,12 @@ Route::get('/reports', function () {
307
306
$report->process(
308
307
public_path() . '/report/hello_world.jrxml', //input
309
308
public_path() . '/report/'.time().'_hello_world', //output
310
- ['pdf', 'rtf', 'xml'], //formats
311
- [], //parameters
312
- [], //data_source
313
- '' //locale
309
+ [
310
+ 'format' => ['pdf', 'rtf', 'xml'],
311
+ 'locale' => 'en',
312
+ 'params' => [],
313
+ 'db_connection' => []
314
+ ];
314
315
)->execute();
315
316
});
316
317
```
@@ -323,131 +324,6 @@ Route::get('/reports', function () {
323
324
324
325
In this example we generate reports pdf, rtf and xml.
325
326
326
-
327
- ###[ optional] Reports from a xml in PHP/Laravel 5.*
328
-
329
- See how easy it is to generate a report with a source an XML file:
330
-
331
- ``` php
332
-
333
- use JasperPHP\JasperPHP;
334
-
335
- public function xmlToPdf()
336
- {
337
- $output = public_path() . '/report/'.time().'_CancelAck';
338
- $ext = "pdf";
339
- $data_file = public_path() . '/report/CancelAck.xml';
340
- $driver = 'xml';
341
- $xml_xpath = '/CancelResponse/CancelResult/ID';
342
- $locale = 'en';
343
-
344
- $php_jasper = new JasperPHP;
345
-
346
- $php_jasper->process(
347
- public_path() . '/report/CancelAck.jrxml', //input
348
- $output, //output
349
- [$ext], //formats
350
- [], //parameters
351
- ['data_file' => $data_file, 'driver' => $driver, 'xml_xpath' => $xml_xpath], //data_source
352
- $locale //locale
353
- )->execute();
354
-
355
- header('Content-Description: File Transfer');
356
- header('Content-Type: application/octet-stream');
357
- header('Content-Disposition: attachment; filename='.time().'_CancelAck.'.$ext);
358
- header('Content-Transfer-Encoding: binary');
359
- header('Expires: 0');
360
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
361
- header('Content-Length: ' . filesize($output.'.'.$ext));
362
- flush();
363
- readfile($output.'.'.$ext);
364
- unlink($output.'.'.$ext);
365
- }
366
- ```
367
-
368
-
369
- ** Do not forget to write your route**
370
-
371
- ``` php
372
- Route::get('reports/xml', 'ReportsController@xmlToPdf');
373
- ```
374
- ** and just go to** :
375
-
376
- http://localhost:8000/reports/xml
377
-
378
- ** Note 3:**
379
-
380
- To use the example above you must copy the sample files located at:
381
-
382
- ** \vendor\geekcom\phpjasper\examples\CancelAck.jrxml**
383
- and
384
- ** \vendor\geekcom\phpjasper\examples\CancelAck.xml**
385
- to folder:
386
- ** \public\report**
387
-
388
-
389
- ###[ optional] Reports from a JSON File in PHP/Laravel 5.*
390
-
391
- See how easy it is to generate a report with a source an JSON file:
392
-
393
- ``` php
394
-
395
- use JasperPHP\JasperPHP;
396
-
397
- public function jsonToPdf()
398
- {
399
- $output = public_path() . '/report/'.time().'_Contacts';
400
- $ext = "pdf";
401
- $driver = 'json';
402
- $json_query= "contacts.person";
403
- $data_file = public_path() . '/report/contacts.json';
404
- $locale = 'en';
405
-
406
- $php_jasper = new JasperPHP;
407
-
408
- $php_jasper->process(
409
- public_path() . '/report/json.jrxml', //input
410
- $output, //output
411
- [$ext], //formats
412
- [], //parameters
413
- ['data_file' => $data_file, 'driver' => $driver, 'json_query' => $json_query],
414
- $locale
415
- )->execute();
416
-
417
- header('Content-Description: File Transfer');
418
- header('Content-Type: application/octet-stream');
419
- header('Content-Disposition: attachment; filename='.time().'_Contacts.'.$ext);
420
- header('Content-Transfer-Encoding: binary');
421
- header('Expires: 0');
422
- header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
423
- header('Content-Length: ' . filesize($output.'.'.$ext));
424
- flush();
425
- readfile($output.'.'.$ext);
426
- unlink($output.'.'.$ext);
427
- }
428
- ```
429
-
430
- ** Do not forget to write your route**
431
-
432
- ``` php
433
- Route::get('reports/json', 'ReportsController@jsonToPdf');
434
- ```
435
-
436
- ** and just go to** :
437
-
438
- http://localhost:8000/reports/json
439
-
440
- ** Note 4:**
441
-
442
- To use the example above you must copy the sample files located at:
443
-
444
- ** \vendor\geekcom\phpjasper\examples\json.jrxml**
445
- and
446
- ** \vendor\geekcom\phpjasper\examples\contacts.json**
447
- to folder:
448
- ** \public\report**
449
-
450
-
451
327
###MySQL
452
328
453
329
We ship the [ MySQL connector] ( http://dev.mysql.com/downloads/connector/j/ ) (v5.1.39) in the ` /src/JasperStarter/jdbc/ ` directory.
485
361
486
362
##[ Contribute] ( https://github.com/geekcom/phpjasper/blob/master/CONTRIBUTING.md )
487
363
488
- Contribute to the community PHP and Laravel, feel free to contribute , make a fork!!
364
+ Contribute to the community PHP, make a fork!!
0 commit comments