KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Phantomjs path #1223

Closed Ralf Föhring opened this topic on on Dec 21, 2019 - 9 comments

Ralf Föhring commented on Dec 21, 2019

Hi,

considering your example below, how should the path look like, should it include the file name too, should it be relative to the export/Handler.php file ?

$report->export()
->settings(array(
    "useLocalTempFolder"=>true,
    "phantomjs"=>"/path/to/phantomjs",
    "resourceWaiting"=>2000,
))
Ralf Föhring commented on Dec 21, 2019

Does the line

 $this->phantomjs.=".exe";

from export/Handler.php throws an error on a linux server ?

 protected function runPhantom($script,$source,$output,$params)
    {
        if(!$this->phantomjs)
        {
            $this->phantomjs = realpath(dirname(__FILE__))."/bin/phantomjs";
            if(!is_file($this->phantomjs))
            {
                $this->phantomjs.=".exe";
                if(!is_file($this->phantomjs))
                {
                    throw new \Exception("Could not find phantomjs executed file in bin folder");
                }
            }    
            if(!is_executable($this->phantomjs))
            {
                throw new \Exception("Please set executable permission for phantomjs");    
            }
        }
Ralf Föhring commented on Dec 27, 2019

I have noticed that the shell_exec($command) is returning an empty result, although I can execute the phantomjs on the server from command line. A tmp file is also created inside the export/tmp folder, but not the .pdf file. Also the export/pdf/pdf.js file has full permissions.

Are any other libraries necessary? Thanks

David Winterburn commented on Dec 31, 2019

Hi Ralf,

In the file "koolreport/export/Hanlder.php", please add the following command:

echo "command=$command<br>"; exit;

to just before this one:

$result = shell_exec($command);

Run export to see the command text. Then copy and paste it to your server's terminal and run it. Let me know the result. Thanks!

Ralf Föhring commented on Jan 3, 2020

Hi, this is the command I had run in the terminal:

/is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs --ignore-ssl-errors=true /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/pdf/pdf.js /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/tmp/5e0f9789e634a1.tmp /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/tmp/5e0f9789e64252.pdf eyJmb3JtYXQiOiJBNCIsImxhbmRzY2FwZSI6dHJ1ZSwicHJpbnRCYWNrZ3JvdW5kIjpmYWxzZSwiZXhwZWN0ZWRMb2NhdGlvbiI6Imh0dHBzOlwvXC9yZXZpZXJyYWQtdGVzdC5waWEtc2VydmljZS5kZTo0NDNcL2luY1wvcmVwb3J0c1wvcmVwb3J0NFwvaW5kZXgucGhwP2xvY2F0aW9uPTE4NyZpbnZlbnRvcnk9MTgiLCJyZXNvdXJjZVdhaXRpbmciOjEwMDB9

and this is the result:

1 0x1b67967 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x1b67967] 2 0x19871af /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x19871af] 3 0x1a8ea33 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x1a8ea33] 4 0x79da8e /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x79da8e] 5 0x79e042 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x79e042] 6 0x797c52 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x797c52] 7 0x778125 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x778125] 8 0x475a4d /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x475a4d] 9 0x423732 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x423732] 10 0x46d98e /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x46d98e] 11 0x22f4ace /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x22f4ace] 12 0x8c7caf /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x8c7caf] 13 0x79d6c3 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x79d6c3] 14 0x79dcab /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x79dcab] 15 0x79e042 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x79e042] 16 0x797c52 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x797c52] 17 0x778125 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x778125] 18 0x475a4d /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x475a4d] 19 0x436483 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x436483] 20 0x41b1c3 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x41b1c3] 21 0x415b91 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x415b91] 22 0x7fa108fdab45 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7fa108fdab45] 23 0x4176a1 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x4176a1] PhantomJS has crashed. Please read the bug reporting guide at http://phantomjs.org/bug-reporting.html and file a bug report. Segmentation fault

David Winterburn commented on Jan 6, 2020

Thanks, Ralf. Would you please run the Page Loading example of PhantomJS with your server:

https://phantomjs.org/quick-start.html#page-loading

Then let us know if it works or not. Thanks!

Ralf Föhring commented on Jan 6, 2020

Hi,

I've packed this is the code to script.js:

console.log('Success');
phantom.exit();

and run it with this command:

~/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs script.js

but the result was the same :

1   0x1b67967 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x1b67967]
2   0x19871af /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x19871af]
3   0x1a8ea33 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x1a8ea33]
4   0x79da8e /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x79da8e]
5   0x79e042 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x79e042]
6   0x797c52 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x797c52]
7   0x778125 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x778125]
8   0x475a4d /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x475a4d]
9   0x423732 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x423732]
10  0x46d98e /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x46d98e]
11  0x22f4ace /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x22f4ace]
12  0x8c7caf /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x8c7caf]
13  0x79d6c3 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x79d6c3]
14  0x79dcab /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x79dcab]
15  0x79e042 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x79e042]
16  0x797c52 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x797c52]
17  0x778125 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x778125]
18  0x475a4d /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x475a4d]
19  0x436483 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x436483]
20  0x41b1c3 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x41b1c3]
21  0x415b91 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x415b91]
22  0x7ff8f7fffb45 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7ff8f7fffb45]
23  0x4176a1 /is/htdocs/wp12809330_BQR7WTGJSR/www/revierrad/test/library/koolreport/koolreport/export/bin/phantomjs() [0x4176a1]
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
Segmentation fault

I also have an answer from the hosting support but it doesn't make much sense to me. They say "We can't support browser which are executable via SSH on our systems.".

David Winterburn commented on Jan 6, 2020

It looks like the current PhantomJS file can't execute successfully on your server environment. I think there're 2 solutions for this case:

  1. Install PhantomJS again by googling some phrase like: how to install phantomjs on Ubuntu 18.04/CentOS 7/etc. You might need to install some libraries for phantomjs' dependencies.

  2. Use our Cloud Export package:

https://www.koolreport.com/packages/cloudexport

If you have any issue with Cloud export, let us know. Thanks!

Ralf Föhring commented on Jan 6, 2020

1.The server host support said :

The script phantomjs can not be run on managed webserver, due to lack of root rights. Phantomjs can be executed on self administratedt servers like virtual server and root server.

Does it makes sense what they say? Because I am not getting a "permission denied" error but a runtime error.

2.The problem I am having with the pivot table and cloud export is that I am getting empty pages. I do get the correct number of pages, but no content.

So it's strange because calling the pivot table cloud export from my local machine runs fine, but from linux the server I am getting empty pages.

Simple text runs fine on both.

Thanks

KoolReport commented on Jan 6, 2020

The phantomjs may require some extra package to be installed in the system (which is not allowed by the hosting provider). Since many of our customer has problem with installing the phantomjs on managed server or shared host so we have made the cloudexport service to ease the pain. So I suggest that you move to cloudexport service or you can use VM for example from DigitalOcean. The price is rather low like $10/server and you have full right. If you are worry about the security, you can use the ServerPilot add-on to setup security and manage server.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed
solved

Export