Edit: I answered my own question, see edit below.
ORIGINAL: I have phantomjs and casperjs installed on my web server and they both run fine. The script I am planning
I found the answer myself.
It seems phantomjs and casperjs support command line arguments http://phantomjs.org/api/system/property/args.html
My script now looks like this.
test.php
$user_input = $_POST['user_input'];
putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs");
exec('/usr/local/bin/casperjs hello.js $user_input 2>&1',$output);
print_r($output);
hello.js
var system = require('system');
var args = system.args;
var address = args[4]; //In my case 4 was the argument for $user_input, yours might be different, depending on your server setup.
var casper = require('casper').create({
verbose: true,
logLevel: 'error',
pageSettings: {
loadImages: false,
loadPlugins: false
}
});
casper.start(address, function() {
this.echo(this.getTitle());
});
casper.run();