Executing CasperJS from a PHP script (ideally Codeigniter)

658 views
Skip to first unread message

Gavin

unread,
Aug 1, 2013, 9:45:30 AM8/1/13
to casp...@googlegroups.com
Hi guys,

I have setup the latest version of CasperJS & PhantomJS (all works well so far) - I want to be able to execute a javascript script with the Casper code in directly from my PHP script - also how is the best way to handle passing data to and from the script.

I am using this with Codeigniter - would there be an library that would be suitable for this?

Robert Igl

unread,
Aug 1, 2013, 10:04:45 AM8/1/13
to casp...@googlegroups.com
You can use exec for this
To pass data just append them after the exec and access it in phantomjs/casperjs via var yourVar = require('system').args[1];
You can pass as much as you want, [1] will just give the first argument passed after the script which should be executed

Gavin

unread,
Aug 1, 2013, 12:00:14 PM8/1/13
to casp...@googlegroups.com
Brilliant Robert - you've been super useful today! :-)

lavesh bhandari

unread,
Aug 20, 2013, 4:50:57 AM8/20/13
to casp...@googlegroups.com
Hi Robert,

I am also looking to run casperJS script via php.
Since I am a very noob in this stuff can you please explain your answer in a bit detail.

Thanks
Reply all
Reply to author
Forward
0 new messages