0

I am trying to run PhantomJS from a PHP script using exec('/path/to/phantomjs/phantonjs --version'); This line works fine from the CLI but does not work at all from my PHP script.

I have searched around for a fix and found this Q/A and read something about permissions that can be the problem. I have try all these fixes and still, PhantomJS does not launch.

I'm desperate at this point, can someone help me out? Thanks.

5
  • Are you expecting that to output something? You need to echo the returned value. Commented Dec 1, 2016 at 1:43
  • I have echoed it and even tried adding an output array as second parameter for exec but the command simply does not run. :( Commented Dec 1, 2016 at 9:14
  • Can you create a minimum version of your script that doesn't work, and post that? Have you been able to get exec to work using the interactive interpreter using php -a? Commented Dec 1, 2016 at 9:42
  • I have PhantomJS in /usr/local/bin. The binary is executable and I have both permissions and ownership. I use a script as simple as $cmd = '/usr/local/bin/phantomjs --version'; This obviously works flawlessly from the CLI but when called from PHP with: $response = exec($cmd, $out, $status) ; The status returns true meaning the command was not executed and both $response and $out are empty. Not null but respectively an empty string and an array of strings with one empty string element. Commented Dec 1, 2016 at 10:51
  • Maybe something in php.ini is preventing it. Commented Dec 1, 2016 at 22:41

2 Answers 2

1

Your path looks wrong in the exec command, it uses phantonjs where I'd expect it to be phantomjs. Might that be the problem?

Sign up to request clarification or add additional context in comments.

1 Comment

Hello @daphtdazz and thanks for your answer. I have tried it and still it doesn't work :(
0

I solved it. PhantomJS required som libraries that were not found in my Xampp packages and was just failing silently and updating the logs. So I just install the standalone PHP and Apache services and everything worked fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.