title: How can I execute casperjs from php?
body: <p>I have a test.js code from manual <a href="http://docs.casperjs.org/en/latest/cli.html" rel="nofollow noreferrer">http://docs.casperjs.org/en/latest/cli.html</a></p>
  
  <pre><code>var casper = require("casper").create();
  
  casper.echo("Casper CLI passed args:");
  require("utils").dump(casper.cli.args);
  
  casper.echo("Casper CLI passed options:");
  require("utils").dump(casper.cli.options);
  
  casper.exit();
  </code></pre>
  
  <p>and I can successfully execute it from the terminal '$ casperjs test.js arg1 arg2 arg3 --foo=bar --plop anotherarg'. It's working and this is good, but I need to execute this from the PHP script, I have tried to do it by PHP code:</p>
  
  <pre><code>&lt;?php
  
  function parser() {
      try {
          echo(exec("C:\casperjs\bin\casperjs.exe  C:\OpenServer\domains\casper\test.js arg1 arg2 arg3 --foo=bar --plop anotherarg"));
          flush();
      } catch (Exception $exc) {
          echo('error!');
          echo $exc-&gt;getTraceAsString();
      }
  }
  
  parser();
  
  putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs");
  putenv("DYLD_LIBRARY_PATH");
  
  ?&gt;
  </code></pre>
  
  <p>But I have got a failure 'phantomjs://code/bootstrap.js:110 in __die'. 
  How can I do it properly? Please help!</p>