execute js function by php command line

前端 未结 2 1036
失恋的感觉
失恋的感觉 2021-01-27 12:17

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 front

相关标签:
2条回答
  • 2021-01-27 12:57

    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/

    0 讨论(0)
  • 2021-01-27 13:14

    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.

    0 讨论(0)
提交回复
热议问题