KoolReport's Forum

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

Another cannot execute phantomjs problem #538

Open Alex Chartier opened this topic on on Nov 29, 2018 - 9 comments

Alex Chartier commented on Nov 29, 2018

Like many others I am experiencing the same issue. shell_exec is available and working. The phantomjs executable has permissions 777 and is version 2.1.1. If I capture the command and execute it from the shell it produces a pdf file (a rather ugly one but we will address that later). I even tried adding 2>&1 to the end of the command piped to shell_exec, no luck.

I have looked through the older posts on the same subject but exhausted all avenues. Could use some assistance.

Thanks in advance.

KoolReport commented on Nov 30, 2018

What is your OS? So as you describe, the phantomjs is running, shell_exec is working, but together is not

Alex Chartier commented on Nov 30, 2018

x86_64 GNU/Linux

Alex Chartier commented on Dec 2, 2018

Any thoughts on this?

KoolReport commented on Dec 3, 2018

So when you run export package, is there any error showing. May be you try to turn on error reporting with error_reporting(E_ALL)

Alex Chartier commented on Dec 3, 2018

OK, I have done some further digging. Firstly the error being reported is that it cannot write to the temporary folder. This is a bit of a red herring because the test for the condition is incorrect. The test is happening on the file_put_content and expecting a true/false response. The test however should be doing === false because the function returns the number of bytes written which in this case is zero and PHP considers to be false. You should change this if statement.

The real issue is that the previous call to $this->report->render in the saveTempContent function is returning no content. This is what is causing the test to fail as described above.

So, I need some assistance in determining why this call is returning no content.

As a side note, on some linux systems sys_get_temp_dir may not return a directory the user has authority to write into. If this happens you can insert the following statement before the call to run in your export->pdf file:

putenv('TMPDIR='.'path to your temp dir');

KoolReport commented on Dec 4, 2018

The export package has extra settings to set the useLocalTempFolder. By setting it to true then it will not use the default tmp dir.

Export Extra Settings

Thank you for your suggestion on the file_put_content and also I will look further on the saveTempContent.

Alex Chartier commented on Dec 4, 2018

I actually tried to use the useLocalTempFolder but did not see any difference. Once I discovered that the problem was really that there was no content I saw that the test for put_file_contents was failing.

Rather than useLocalTempFolder I think it would be better to allow the definition of a specific temp folder. I doubt most people would want to place temp files in the library folder.

I await your further analysis of the no content issue.

Alex Chartier commented on Dec 19, 2018

Found a number of things. First, one needs to make sure one installs the correct version of phantomjs, 32b or 64b. As it turns out my test system is 32b but my production system is 64b. This complicates testing as I need to ensure I have the correct version installed. (I clone my production site to a test system for testing so I have to remember to switch out the phantomjs version when I load the clone).

Second, I found that I was using the wrong view name in the run()->export('viewname'). In my case the filename was EventPrintChoices.pdf.view.php and this is what I had in the 'viewname' when in fact the 'viewname' needs to be the part before the '.view.php' so in my case it needed to be 'EventPrintChoices.pdf'.

pdf export is now working.

KoolReport commented on Dec 19, 2018

Awesome, that's great finding :)

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
solved

Export