Access Codeigniter functions from external script

我是研究僧i 提交于 2019-12-24 09:08:07

问题


So, here's my situation :

  • I have a complete app set up with CodeIgniter.
  • I'm initiating a background task, running a PHP script.

My question :

  • How could I use CodeIgniter function (e.g. $this->db or $CI->db - doesn't matter) from that external PHP script?

Idea : Could a workaround, like include 'index.php'; at the top of the script do the trick?


回答1:


In recent Codeigniter versions you can run standard controller actions from command line. If your task is some kind of a daemon you can embed the "task trigger" logic in a long running part of your script and shell out for the actual work to CI land.



来源:https://stackoverflow.com/questions/11735455/access-codeigniter-functions-from-external-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!