Hello to the CI community!
I have a fundamental question about the whether running via the CLI has any inherent limitations, versus calling via a standard HTTP request.
Specifically, I have a CI app that includes a custom controller designed to be called at regular intervals via a cron job. This controller carries out a variety of tasks, including querying the database and sending out emails. It extends my custom MY_Controller and leverages multiple CI helper functions and libraries. In testing I've found that I can call this controller successfully via the CLI like so:
Code:
*/5 * * * * cd /path/to/app/index; php index.php Cron_controller cron_method >/dev/null 2>&1
, following the example laid out in the user guide. For the most part this works, but it seems that my Cron_controller doesn't have access to all of the CI functions and variables that I would expect. Base_url() doesn't return anything and template variables that are expected by my view files aren't found, to name a few.
If I call this controller directly with an HTTP request, base_url() and other helper functions and variables work as expected. It's only when I call this via the CLI that the expected values don't come through.
Why does my controller behave differently when invoked via the CLI?