Closed AdeSupriyadi closed 4 years ago
Replace ->execute(); for ->output();.
It will print the command to put in console and get more details of the error
I change ->execute();
to ->output();
Examples.php
{
$input = __DIR__ . '/input/json.jrxml';
$output = __DIR__ . '/output';
$data_file = __DIR__ . '/data_files/contacts.json';
$options = [
'format' => ['pdf'],
'params' => [],
'locale' => 'en',
'db_connection' => [
'driver' => 'json',
'data_file' => $data_file,
'json_query' => 'contacts.person'
]
];
// $this->PHPJasper->process(
// $input,
// $output,
// $options
// )->execute();
return $this->PHPJasper->process(
$input,
$output,
$options
)->output();
}
}
And in Index.php:
use Examples\Examples;
$examples = new Examples;
var_dump($examples->JsonExample());
It outputs in browser:
string(276) "./jasperstarter --locale en process "/home/ade/researces/php/jasper-example/src/input/json.jrxml" -o "/home/ade/researces/php/jasper-example/src/output" -f pdf -t json --data-file /home/ade/researces/php/jasper-example/src/data_files/contacts.json --json-query contacts.person"
And outputs in console/terminal:
127.0.0.1:40684 [500]: GET / - Uncaught PHPJasper\Exception\ErrorCommandExecutable: 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. in /home/ade/researces/php/jasper-example/vendor/geekcom/phpjasper/src/PHPJasper.php:250
Stack trace:
#0 /home/ade/researces/php/jasper-example/src/Examples.php(156): PHPJasper\PHPJasper->execute()
#1 /home/ade/researces/php/jasper-example/index.php(35): Examples\Examples->JsonExample()
#2 {main}
thrown in /home/ade/researces/php/jasper-example/vendor/geekcom/phpjasper/src/PHPJasper.php on line 250
You ran command ./jasperstarter --locale en process "/home/ade/researces/php/jasper-example/src/input/json.jrxml" -o "/home/ade/researces/php/jasper-example/src/output" -f pdf -t json --data-file /home/ade/researces/php/jasper-example/src/data_files/contacts.json --json-query contacts.person
on the console?
You are processing a ".jrxml" when you actually have to process a ".jasper"
The ".jrxml" file is for compilation.
Error Fatal Error
I follow the step in doc, but I show the error. I was browsing but no lucky
error:
Fatal error: Uncaught PHPJasper\Exception\ErrorCommandExecutable: 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. in /var/www/html/jasperphp/vendor/geekcom/phpjasper/src/PHPJasper.php:250 Stack trace: #0 /var/www/html/jasperphp/src/Example.php(21): PHPJasper\PHPJasper->execute() #1 /var/www/html/jasperphp/index_old.php(15): Example\Example->JsonCompile() #2 {main} thrown in /var/www/html/jasperphp/vendor/geekcom/phpjasper/src/PHPJasper.php on line 250
Desktop (please complete the following information):