Welcome Guest, Not a member yet? Register   Sign In
Running controller from command line using CLI
#1

[eluser]rankorn[/eluser]
I have a CI application and I want to run some code from a CRON job.
The solution I am thinking of is to call the PHP CLI interface as the CRON job, and run a part of my application. I want to use the CI framework since the job requires my models and some more CI libraries.

I have found a nice way to run controller from CLI on one of the threads, and it works fine except for a small problem I have on Windows.

This is the cli.php that I call from CLI to ignite my controller:
Code:
<?php

if ($_SERVER['SCRIPT_FILENAME'] != 'cli.php') {
    echo 'no web access';
    exit;
}

ini_set('max_execution_time','0');
set_time_limit(0);

$_SERVER['PATH_INFO']    = $argv[1];
$_SERVER['QUERY_STRING'] = $argv[1];

require('index.php');

It seems that on windows, when I try to invoke the parent constructor from my controller, it fails without any shown error, and the script just dies. This DOES NOT happen on my linux machine.
I managed to track the exact problem to calling the base constructor. I have found that all the classes are loaded and that it is not an include_path problem.

Any ideas?

Ran.




Theme © iAndrew 2016 - Forum software by © MyBB