Access Codeigniter functions from external script

2019-07-23 03:37发布

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条回答
再贱就再见
2楼-- · 2019-07-23 04:13

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.

查看更多
登录 后发表回答