Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
It could also be a temporary directory's write permission issue. Pls try to use a local temp like this:
$report->run()
->export("MyReportPDF")
->settings([
'useLocalTempFolder' => true,
])
->pdf(...)
...
Make sure your php user has write permission to the report's current directory (so that a temp dir and temp files could be created).
If this still doesn't solve the issue, pls open the file koolreport/export/Handler.php
and replace this line:
$result = shell_exec($command);
with these ones:
echo "command = $command<br>"; exit;
// $result = shell_exec($command);
Then run export and copy/paste the echoed command to your terminal to see if it can run or return any error. Let us know the result. Tks,
Hi. I am actually using this:
$this->exec_summary(); //build the array
$report = new MyExecutive_summary;
$this->output->set_template('blank');
$szFilename=sprintf("Executive_summary-%s-%s.pdf",$this->session->userdata('campaign'),$this->session->userdata('last_TY'));
$report->export()->pdf(array(
"format"=>"A4",
"orientation"=>"portrait"
))->toBrowser($szFilename, FALSE); // Input the filename make this true to pop open a window
I tried changing from FALSE to TRUE. My debugger is down so I can't check the $szFilename. Could that be the issue?
Could it be that you forgot to run $report->run() before export it? Pls try this command and let us know the result:
$report
->run(); //add this method call
->export()
->pdf(array(
"format"=>"A4",
"orientation"=>"portrait"
))
->toBrowser($szFilename, FALSE);
Here is the code. Are you saying to $report->run() without the ->render()?
$report = new MyNexusReport;
$report->run()->render();
$this->output->set_template('blank');
$szFilename=sprintf("Specificity_report-%s-%s.pdf",$this->session->userdata('campaign'),$this->session->userdata('last_TY'));
$report->export()->pdf(array(
"format"=>"A4",
"orientation"=>"portrait"
))->toBrowser($szFilename, FALSE); // Input the filename make this true to pop open a window
Pls try the steps in my previous post and let me know the result:
>>Make sure your php user has write permission to the report's current directory (so that a temp dir and temp files could be created).
What directory is the current report directory? I stopped the code in Handler.php with my debugger and when I look at FILE on line 113, I see "xdebug://debug-eval(1) : eval()'d code". I thought I would see a directory. What can I do?
I ran the echo command you mentioned above and then tried to run it in the terminal (on the server). this is what I got: ubuntu@ip-172-31-66-201:~$ command=/app/vendor/koolreport/export/bin/phantomjs --ignore-ssl-errors=true /app/vendor/koolreport/export/pdf/pdf.js /tmp/61af843c699522.tmp /tmp/61af843c6adab3.pdf eyJmb3JtYXQiOiJBNCIsIm9yaWVudGF0aW9uIjoicG9ydHJhaXQiLCJleHBlY3RlZExvY2F0aW9uIjoiaHR0cDpcL1wvc3RhZ2luZy5kYXNoYm9hcmQucmVzZWFyY2hzdHVkeW9ubGluZS5jb21cL2luZGV4LnBocFwvQ29uZmlndXJlXC9leGVjdXRpdmVfc3VtbWFyeSIsInJlc291cmNlV2FpdGluZyI6MTAwMH0= --ignore-ssl-errors=true: command not found
1 . The local temp directory locates where your report setup and view files are, not inside "vendor/koolreport/export".
2 . Pls check phantomjs' screen capture examples with your installation at /app/vendor/koolreport/export/bin/phantomjs
:
That could be the issue. When I look at printenv on the server I see:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Notice that the path with phantomjs is not on this. Should I modify the /etc/sysconfig/httpd to also have
/home/ubuntu/rst/RST/app/vendor/koolreport/export/bin
???
I grabbed the command trying to run phantomjs and removed the first "/" and at least it is found.
ubuntu@ip-172-31-66-201:~/rst/RST$ /app/vendor/koolreport/export/bin/phantomjs --ignore-ssl-errors=true /app/vendor/koolreport/export/pdf/pdf.js /tmp/61b0f98de8bb62.tmp /tmp/61b0f98de8e5f3.pdf eyJmb3JtYXQiOiJBNCIsIm9yaWVudGF0aW9uIjoicG9ydHJhaXQiLCJleHBlY3RlZExvY2F0aW9uIjoiaHR0cDpcL1wvc3RhZ2luZy5kYXNoYm9hcmQucmVzZWFyY2hzdHVkeW9ubGluZS5jb21cL2luZGV4LnBocFwvQ29uZmlndXJlXC9leGVjdXRpdmVfc3VtbWFyeSIsInJlc291cmNlV2FpdGluZyI6MTAwMH0=
-bash: /app/vendor/koolreport/export/bin/phantomjs: No such file or directory
ubuntu@ip-172-31-66-201:~/rst/RST$ ls /app/vendor/koolreport/export/bin/phantomjs
ls: cannot access '/app/vendor/koolreport/export/bin/phantomjs': No such file or directory
ubuntu@ip-172-31-66-201:~/rst/RST$ ls app/vendor/koolreport/export/bin/phantomjsapp/vendor/koolreport/export/bin/phantomjs
ubuntu@ip-172-31-66-201:~/rst/RST$ app/vendor/koolreport/export/bin/phantomjs --ignore-ssl-errors=true /app/vendor/koolreport/export/pdf/pdf.js /tmp/61b0f98de8bb62.tmp /tmp/61b0f98de8e5f3.pdf eyJmb3JtYXQiOiJBNCIsIm9yaWVudGF0aW9uIjoicG9ydHJhaXQiLCJleHBlY3RlZExvY2F0aW9uIjoiaHR0cDpcL1wvc3RhZ2luZy5kYXNoYm9hcmQucmVzZWFyY2hzdHVkeW9ubGluZS5jb21cL2luZGV4LnBocFwvQ29uZmlndXJlXC9leGVjdXRpdmVfc3VtbWFyeSIsInJlc291cmNlV2FpdGluZyI6MTAwMH0=
Error: Cannot find module '../common/base64_decode'
phantomjs://platform/bootstrap.js:299 in require
phantomjs://platform/bootstrap.js:263 in require
Since I can't get Export to run I am going to build the report to the screen and then a user can print the screen. I am using this
public function nexus_report()
{
$report2 = new MyNexusReport;
$report2->run()->render();
But I need this report to be rendered in a new tab. How can I do this?
I think we can still try to fix the phantomjs path issue. Pls try to set phantomjs path directly in setting like this:
$report->run()->export("MyReportPDF")
->settings([
'useLocalTempFolder' => true,
'autoDeleteLocalTempFile' => true,
'phantomjs' => 'path/to/your/phantomjs',
])
->pdf(...)
...
Still keep this output command in Handler.php:
echo "command = $command<br>"; exit;
// $result = shell_exec($command);
Then copy/paste the output phantomjs command to your terminal to see how it runs. Let us know the result. Tks,
richb201@richb201-XPS-13-9370:~$ app/vendor/koolreport/export/bin/phantomjs --ignore-ssl-errors=true /app/vendor/koolreport/export/pdf/pdf.js /app/vendor/koolreport/export/tmp/61b7571ff1d356.tmp /app/vendor/koolreport/export/tmp/61b7572848af17.pdf eyJmb3JtYXQiOiJBNCIsIm9yaWVudGF0aW9uIjoicG9ydHJhaXQiLCJleHBlY3RlZExvY2F0aW9uIjoiaHR0cDpcL1wvc3RhZ2luZy5kYXNoYm9hcmQucmVzZWFyY2hzdHVkeW9ubGluZS5jb21cL2luZGV4LnBocFwvQ29uZmlndXJlXC9uZXh1c19yZXBvcnQiLCJyZXNvdXJjZVdhaXRpbmciOjEwMDB9
bash: app/vendor/koolreport/export/bin/phantomjs: No such file or directory
ubuntu@ip-172-31-66-201:~/rst/RST$ ~/rst/RST/app/vendor/koolreport/export/bin/phantomjs --ignore-ssl-errors=true /app/vendor/koolreport/export/pdf/pdf.js /app/vendor/koolreport/export/tmp/61b75e68b68036.tmp /app/vendor/koolreport/export/tmp/61b75e68b6ab37.pdf eyJmb3JtYXQiOiJBNCIsIm9yaWVudGF0aW9uIjoicG9ydHJhaXQiLCJleHBlY3RlZExvY2F0aW9uIjoiaHR0cDpcL1wvc3RhZ2luZy5kYXNoYm9hcmQucmVzZWFyY2hzdHVkeW9ubGluZS5jb21cL2luZGV4LnBocFwvQ29uZmlndXJlXC9uZXh1c19yZXBvcnQiLCJyZXNvdXJjZVdhaXRpbmciOjEwMDB9
Error: Cannot find module '../common/base64_decode'
phantomjs://platform/bootstrap.js:299 in require
phantomjs://platform/bootstrap.js:263 in require
OK. I did that. phantomjs -v returns 2.1.1. I then ran my code and it printed this which I then ran from the CLI:
ubuntu@ip-172-31-66-201:~$ phantomjs --ignore-ssl-errors=true /app/vendor/koolreport/export/pdf/pdf.js /tmp/61b9eeb9320de2.tmp /tmp/61b9eeb9322f93.pdf eyJmb3JtYXQiOiJBNCIsIm9yaWVudGF0aW9uIjoicG9ydHJhaXQiLCJleHBlY3RlZExvY2F0aW9uIjoiaHR0cDpcL1wvc3RhZ2luZy5kYXNoYm9hcmQucmVzZWFyY2hzdHVkeW9ubGluZS5jb21cL2luZGV4LnBocFwvQ29uZmlndXJlXC9leGVjdXRpdmVfc3VtbWFyeSIsInJlc291cmNlV2FpdGluZyI6MTAwMH0=
Can't open '/app/vendor/koolreport/export/pdf/pdf.js'
I
Sebastian, I will check. I do not think that koolreport was installed on the EC2 server. Rather, it was copied to the EC2 server from my laptop. Could a reinstall directly to the EC2 help?
I tried to acces it via the cli but it is not found. Then I looked for it with filezilla. I can see that it is there. File permissions is 644. On my listing from printenv below you can see it is not there. Are there certain paths that need to be set up to allow koolreport to work properly?
ubuntu@ip-172-31-66-201:~$ cat /app/vendor/koolreport/export/pdf/pdf.js
cat: /app/vendor/koolreport/export/pdf/pdf.js: No such file or directory
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ubuntu/rst/RST/app/vendor/koolreport/export/bin
I think that when you copy KoolReport directory from your machine to EC2 somehow your webserver could not either figure out the exact file path or at least access the path it has for KoolReport directory (in this case: /app/vendor/koolreport
).
Maybe a direct KoolReport install with composer via terminal on EC2 could help. Pls try it.
Regarding system path, in most cases webservers know the path to a directory or a file in their web directory so there's no need to set any system path. You only need to set one for phantomjs if you install it outside of koolreport/export/bin
.
Well, as a "joke" I ran printenv on my Ubuntu laptop (where it runs fine). Here is what it printed:
PATH=/usr/lib/jvm/java-8-oracle/bin:/home/richb201/.npm-global/bin:/home/richb201/bin:/opt/gradle/gradle-5.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/richb201/Vault:/usr/local/java/jdk1.7.0_80/bin:/usr/local/java/jdk1.7.0_80/bin:/Home/richb201/Android/Sdk/emulator:/Home/richb201/Android/Sdk/tools:/Home/richb201/Android/Sdk/platform-tools:/home/richb201/Android/Sdk/emulator:/home/richb201/Android/Sdk/tools:/home/richb201/Android/Sdk/tools/bin:/home/richb201/Android/Sdk/platform-tools:/home/richb201/Documents/Android/sdk:/home/richb201/Documents/Android/Sdk/tools:/home/richb201/Android/tools/bin:/usr/bin/javac:/home/richb201/Documents/Android/sdk/platform-tools:/home/richb201/.npm-global/bin:/usr/lib/jvm/java-8-oracle/bin:/opt/gradle/gradle-5.0/bin
There is lots of stuff but I don't see koolreport at all. So that probably is not it. Can I change the rights to the entire koolreport directory (on the EC2 server) at the same time?
The problem is not system/environment path. It's that your webserver can not get the path to KoolReport directory. To it the path is /app/vendor/koolreport
which in reality doesn't exist. I still recommend installing KoolReport directly on your EC2 instance and see if it solves this web directory path problem.
OK. I ran composer on the EC2 server. Am I OK?
ubuntu@ip-172-31-66-201:~/rst/RST$ composer require koolreport/core
Warning from https://packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Using version ^5.5 for koolreport/core
./composer.json has been updated
Loading composer repositories with package information
Warning from https://packagist.org: Support for Composer 1 is deprecated and some packages will not be available. You should upgrade to Composer 2. See https://blog.packagist.com/deprecating-composer-1-support/
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing koolreport/core (5.5.0): Downloading (100%)
Writing lock file
Generating autoload files
BTW, it is still not working. Do I need to upgrade to composer 2 first? It seems to have installed koolreport/core.
Your composer only install koolreport/core. Pls set the composer.json and auth.json so that you install koolreport/export or koolreport/pro as well:
https://www.koolreport.com/docs/export/overview/#installation-by-composer
It seems that the problem is line 50 of Handler.php. This is what the line shows:
$this->phantomjs = realpath(dirname(__FILE__))."/bin/phantomjs";
What $this->phantomjs returns is /app/vendor/koolreport/export/bin/phantomjs
But realpath should return /home/ubuntu/rst/RST/app/vendor/koolreport/export/bin/phantomjs which is the full path.
SYNOPSIS top
realpath [OPTION]... FILE...
DESCRIPTION top
Print the resolved absolute file name; all but the last component
must exist
-e, --canonicalize-existing
all components of the path must exist
-m, --canonicalize-missing
no path components need exist or be a directory
-L, --logical
resolve '..' components before symlinks
-P, --physical
resolve symlinks as encountered (default)
-q, --quiet
suppress most error messages
--relative-to=DIR
print the resolved path relative to DIR
--relative-base=DIR
print absolute paths unless paths below DIR
-s, --strip, --no-symlinks
don't expand symlinks
-z, --zero
end each output line with NUL, not newline
--help display this help and exit
--version
output version information and exit
Yes, you judged the problem correctly. We are still trying to figure out why realpath didn't return real paths to phantomjs and export's js files for your case. Even if you use symlinks realpath can still find the correct absolute paths because resolving symlinks is on by default.
We can not replicate your problem (real path to phantomjs and export's resource files) on both your test and server environments so it's very hard to solve your case. If you still want to solve this pls email us (support@koolreport.com / support@koolphp.net) access to your test/server environment where this issue happens. Tks,
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo