Skip to content

Commit e335dd1

Browse files
author
Daniel Rodrigues Lima
committed
general and README.md update
1 parent d8bafe8 commit e335dd1

File tree

4 files changed

+86
-87
lines changed

4 files changed

+86
-87
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Keep your code clean and organized, happy code.
1+
**Keep your code clean and organized, happy code.**

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Reports for PHP and Laravel 5.*, with JasperReports.
1+
# PHP reports with Jasper Reports, [optional] Laravel 5.*
22

33
[![StyleCI](https://styleci.io/repos/46984485/shield?branch=master)](https://styleci.io/repos/46984485)
44
[![CircleCI](https://circleci.com/gh/geekcom/phpjasper/tree/master.svg?style=shield)](https://circleci.com/gh/geekcom/phpjasper/tree/master)
@@ -47,6 +47,7 @@ Package to generate reports with [JasperReports 6.3.1](http://community.jasperso
4747
* PHP [exec()](http://php.net/manual/function.exec.php) function
4848
* [optional] [Mysql Connector](http://dev.mysql.com/downloads/connector/j/) (if you want to use database)
4949
* [optional] [PostgreSQL Connector](https://jdbc.postgresql.org/download.html) (if you want to use database)
50+
* [optional] [Microsoft JDBC Drivers](https://www.microsoft.com/en-US/download/details.aspx?id=11774) (if you want to use database)
5051
* [optional] [Jaspersoft Studio](http://community.jaspersoft.com/project/jaspersoft-studio) (to draw and compile your reports)
5152

5253
###Java(JDK)
@@ -449,16 +450,20 @@ I have a report that generates a *Invoice* with a DB connection, images and mult
449450

450451
##Thanks
451452

452-
Thanks to [Cenote GmbH](http://www.cenote.de/) for the [JasperStarter](http://jasperstarter.sourceforge.net/) tool.
453+
[Cenote GmbH](http://www.cenote.de/) for the [JasperStarter](http://jasperstarter.sourceforge.net/) tool.
453454

454-
##Questions?
455+
[JetBrains](https://www.jetbrains.com/) for the [PhpStorm](PhpStorm) and all great tools.
455456

456-
Open a [Issue](https://github.com/geekcom/phpjasper/issues)
457457

458-
##License
458+
##[Questions?](https://github.com/geekcom/phpjasper/issues)
459+
460+
Open a new [Issue](https://github.com/geekcom/phpjasper/issues) or look for a closed issue
461+
462+
463+
##[License](https://github.com/geekcom/phpjasper/blob/master/LICENSE)
459464

460465
MIT
461466

462-
##Contribute
467+
##[Contribute](https://github.com/geekcom/phpjasper/blob/master/CONTRIBUTING.md)
463468

464469
Contribute to the community PHP and Laravel, feel free to contribute, make a fork!!

composer.json

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
{
2-
"name": "geekcom/phpjasper",
3-
"description": "Create Reports in PHP/Laravel with JasperReports",
4-
"license": "MIT",
5-
"keywords": [
6-
"reports",
7-
"jasper",
8-
"jasperreports",
9-
"pdf",
10-
"xml",
11-
"PHP",
12-
"java",
13-
"json"
14-
],
15-
"homepage": "https://github.com/geekcom/phpjasper",
16-
"authors": [
17-
{
18-
"name": "Daniel Rodrigues",
19-
"email": "[email protected]",
20-
"homepage": "https://olamundophp.wordpress.com/",
21-
"role": "Developer"
22-
},
23-
{
24-
"name": "Leandro Bitencourt",
25-
"email": "[email protected]",
26-
"homepage": "http://www.leandrobitencourt.zz.mu",
27-
"role": "Developer"
28-
}
29-
30-
],
31-
"minimum-stability": "dev",
32-
"require": {
33-
"php": ">=5.4.0"
2+
"name": "geekcom/phpjasper",
3+
"description": "Create Reports in PHP/Laravel with JasperReports",
4+
"license": "MIT",
5+
"keywords": [
6+
"reports",
7+
"jasper",
8+
"jasperreports",
9+
"pdf",
10+
"xml",
11+
"PHP",
12+
"java",
13+
"json"
14+
],
15+
"homepage": "http://geekcom.github.io/phpjasper/",
16+
"authors": [
17+
{
18+
"name": "Daniel Rodrigues Lima",
19+
"email": "[email protected]",
20+
"homepage": "https://olamundophp.wordpress.com/",
21+
"role": "Owner/Developer"
3422
},
35-
"autoload": {
36-
"psr-0": {
37-
"JasperPHP": "src/"
38-
}
23+
{
24+
"name": "Leandro Bitencourt",
25+
"email": "[email protected]",
26+
"homepage": "http://www.leandrobitencourt.zz.mu",
27+
"role": "Developer"
3928
}
29+
],
30+
"minimum-stability": "dev",
31+
"require": {
32+
"php": ">=5.4.0"
33+
},
34+
"autoload": {
35+
"psr-0": {
36+
"JasperPHP": "src/"
37+
}
38+
}
4039
}

src/JasperPHP/JasperPHP.php

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function __construct($resource_dir = false)
1818
{
1919
$this->path_executable = __DIR__ . '/../JasperStarter/bin'; //Path to executable
2020
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
21-
$this->windows = true;
21+
$this->windows = true;
2222

2323
if (!$resource_dir) {
2424
$this->resource_directory = __DIR__ . '/../../../vendor/geekcom/jasperphp/src/JasperStarter/bin';
@@ -41,7 +41,7 @@ public static function __callStatic($method, $parameters)
4141

4242
public function compile($input_file, $output_file = false, $background = true, $redirect_output = true)
4343
{
44-
if(is_null($input_file) || empty($input_file))
44+
if (is_null($input_file) || empty($input_file))
4545
throw new \Exception('No input file', 1);
4646

4747
$command = ($this->windows) ? $this->executable : './' . $this->executable;
@@ -50,31 +50,29 @@ public function compile($input_file, $output_file = false, $background = true, $
5050

5151
$command .= "\"$input_file\"";
5252

53-
if( $output_file !== false )
53+
if ($output_file !== false)
5454
$command .= ' -o ' . "\"$output_file\"";
5555

56-
$this->redirect_output = $redirect_output;
57-
$this->background = $background;
58-
$this->the_command = $command;
56+
$this->redirect_output = $redirect_output;
57+
$this->background = $background;
58+
$this->the_command = $command;
5959

6060
return $this;
6161
}
6262

6363
public function process($input_file, $output_file = false, $format = array('pdf'), $parameters = array(), $db_connection = array(), $locale = false, $background = true, $redirect_output = true)
6464
{
65-
if(is_null($input_file) || empty($input_file))
65+
if (is_null($input_file) || empty($input_file))
6666
throw new \Exception('No input file', 1);
6767

68-
if( is_array($format) )
69-
{
70-
foreach ($format as $key)
71-
{
72-
if( !in_array($key, $this->formats))
68+
if (is_array($format)) {
69+
foreach ($format as $key) {
70+
if (!in_array($key, $this->formats))
7371
throw new \Exception('Invalid format!', 1);
7472
}
7573
} else {
76-
if( !in_array($format, $this->formats))
77-
throw new \Exception('Invalid format!', 1);
74+
if (!in_array($format, $this->formats))
75+
throw new \Exception('Invalid format!', 1);
7876
}
7977

8078
$command = ($this->windows) ? $this->executable : './' . $this->executable;
@@ -85,78 +83,75 @@ public function process($input_file, $output_file = false, $format = array('pdf'
8583

8684
$command .= "\"$input_file\"";
8785

88-
if( $output_file !== false )
86+
if ($output_file !== false)
8987
$command .= ' -o ' . "\"$output_file\"";
9088

91-
if( is_array($format) )
89+
if (is_array($format))
9290
$command .= ' -f ' . join(' ', $format);
9391
else
9492
$command .= ' -f ' . $format;
95-
96-
97-
if( count($parameters) > 0 )
98-
{
93+
94+
95+
if (count($parameters) > 0) {
9996
$command .= ' -P ';
10097

101-
foreach ($parameters as $key => $value)
102-
{
98+
foreach ($parameters as $key => $value) {
10399
$param = $key . '="' . $value . '" ';
104-
$command .= " " .$param. " ";
100+
$command .= " " . $param . " ";
105101
}
106102

107103
}
108104

109-
if( count($db_connection) > 0 )
110-
{
105+
if (count($db_connection) > 0) {
111106
$command .= ' -t ' . $db_connection['driver'];
112107

113-
if(isset($db_connection['username']))
108+
if (isset($db_connection['username']))
114109
$command .= " -u " . $db_connection['username'];
115110

116-
if( isset($db_connection['password']) && !empty($db_connection['password']) )
111+
if (isset($db_connection['password']) && !empty($db_connection['password']))
117112
$command .= ' -p ' . $db_connection['password'];
118113

119-
if( isset($db_connection['host']) && !empty($db_connection['host']) )
114+
if (isset($db_connection['host']) && !empty($db_connection['host']))
120115
$command .= ' -H ' . $db_connection['host'];
121116

122-
if( isset($db_connection['database']) && !empty($db_connection['database']) )
117+
if (isset($db_connection['database']) && !empty($db_connection['database']))
123118
$command .= ' -n ' . $db_connection['database'];
124119

125-
if( isset($db_connection['port']) && !empty($db_connection['port']) )
120+
if (isset($db_connection['port']) && !empty($db_connection['port']))
126121
$command .= ' --db-port ' . $db_connection['port'];
127122

128-
if( isset($db_connection['jdbc_driver']) && !empty($db_connection['jdbc_driver']) )
123+
if (isset($db_connection['jdbc_driver']) && !empty($db_connection['jdbc_driver']))
129124
$command .= ' --db-driver ' . $db_connection['jdbc_driver'];
130125

131-
if( isset($db_connection['jdbc_url']) && !empty($db_connection['jdbc_url']) )
126+
if (isset($db_connection['jdbc_url']) && !empty($db_connection['jdbc_url']))
132127
$command .= ' --db-url ' . $db_connection['jdbc_url'];
133128

134-
if ( isset($db_connection['jdbc_dir']) && !empty($db_connection['jdbc_dir']) )
129+
if (isset($db_connection['jdbc_dir']) && !empty($db_connection['jdbc_dir']))
135130
$command .= ' --jdbc-dir ' . $db_connection['jdbc_dir'];
136131

137-
if ( isset($db_connection['db_sid']) && !empty($db_connection['db_sid']) )
132+
if (isset($db_connection['db_sid']) && !empty($db_connection['db_sid']))
138133
$command .= ' --db-sid ' . $db_connection['db_sid'];
139134

140-
if ( isset($db_connection['xml_xpath']) )
135+
if (isset($db_connection['xml_xpath']))
141136
$command .= ' --xml-xpath ' . $db_connection['xml_xpath'];
142137

143-
if ( isset($db_connection['data_file']) )
138+
if (isset($db_connection['data_file']))
144139
$command .= ' --data-file ' . $db_connection['data_file'];
145140

146-
if ( isset($db_connection['json_query']) )
141+
if (isset($db_connection['json_query']))
147142
$command .= ' --json-query ' . $db_connection['json_query'];
148143
}
149144

150-
$this->redirect_output = $redirect_output;
151-
$this->background = $background;
152-
$this->the_command = $command;
145+
$this->redirect_output = $redirect_output;
146+
$this->background = $background;
147+
$this->the_command = $command;
153148

154149
return $this;
155150
}
156151

157152
public function list_parameters($input_file)
158153
{
159-
if(is_null($input_file) || empty($input_file))
154+
if (is_null($input_file) || empty($input_file))
160155
throw new \Exception('No input file', 1);
161156

162157
$command = ($this->windows) ? $this->executable : './' . $this->executable;
@@ -178,20 +173,20 @@ public function output()
178173
public function execute($run_as_user = false)
179174
{
180175

181-
if( $run_as_user !== false && strlen($run_as_user > 0) && !$this->windows )
176+
if ($run_as_user !== false && strlen($run_as_user > 0) && !$this->windows)
182177
$this->the_command = 'su -u ' . $run_as_user . " -c \"" . $this->the_command . "\"";
183178

184179
$output = array();
185180
$return_var = 0;
186181

187-
if (is_dir($this->path_executable)){
182+
if (is_dir($this->path_executable)) {
188183
chdir($this->path_executable);
189184
exec($this->the_command, $output, $return_var);
190185
} else {
191186
throw new \Exception('Invalid resource directory.', 1);
192187
}
193188

194-
if($return_var != 0)
189+
if ($return_var != 0)
195190
throw new \Exception('Your report has an error and couldn \'t be processed!\ Try to output the command using the function `output();` and run it manually in the console.', 1);
196191

197192
return $output;

0 commit comments

Comments
 (0)