Skip to content Skip to sidebar Skip to footer

Execute Js Function By Php Command Line

I am working in Codeigniter. I have a view, book.php, with a js file, frontend_book.js, running behind it containing a function to sync the calendar. Snippet from frontend_book.js

Solution 1:

if, for what ever reason, you wanted to run this as a cron, and you wanted to maintain the application as it is now (mvc written in php) then you could use a headless browser (such as phantomjs) to hit the desired url from a bash script that is run as a cron. This is a bit convoluted - but it would do what you wanted. - there is even a php package if you wanted to keep it all via php - http://jonnnnyw.github.io/php-phantomjs/

Solution 2:

You can't make js run from the command line. It only runs in browsers and other environments set up to execute it. Everything you want to do you'll have to do in PHP or another language that runs on the command line.

Post a Comment for "Execute Js Function By Php Command Line"