Welcome Guest, Not a member yet? Register   Sign In
CLI access missing variables
#1

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?
Reply


Messages In This Thread
CLI access missing variables - by Sam - 05-18-2017, 03:15 PM
RE: CLI access missing variables - by kilishan - 05-18-2017, 07:36 PM
RE: CLI access missing variables - by Sam - 05-19-2017, 11:14 AM
RE: CLI access missing variables - by rtenny - 05-26-2017, 07:39 AM



Theme © iAndrew 2016 - Forum software by © MyBB