php - Codeigniter CLI access without arguments -


i need run specific job through cli, can select file - i can't put arguments in there. now, ho make work?

i've tried creating cli_job.php , running through cli, returns homepage:

<?php  /* make sure isn't called web browser */ if (isset($_server['remote_addr'])) die('cli-only access.');  /* set controller/method path */ $_server['path_info'] = $_server['request_uri'] = $_server['query_string'] = '/controller/method'; $_server["http_host"] = "domain.com"; $argv = array("index.php", "controller", "method");  /* call framework */ include(dirname(__file__).'/index.php'); 

thank you

if want run codeigniter controller via cli, need call via command line, not via include.

try set cron script this:

<?php // set options cli script want call $index = 'index.php'; $controller = 'controller'; $method = 'method'; $params = array();  // execute cli script chdir(dirname(__file__)); $passedparams = implode(' ', array_map('escapeshellarg', $params)); exec("php {$index} {$controller} {$method} {$passedparams}"); 

check docs codeigniter's cli here: http://ellislab.com/codeigniter/user-guide/general/cli.html

note: works latest codeigniter version (2.1.4), i'm not sure if works older versions.


update: looking through old codeigniter project, , found file may help.

<?php    $_get["/controller/method"] = null;    require "index.php"; ?> 

i haven't tested this, may work. i'm not sure on documentation this, or made file, in project, might work.


if else fails, this:

file_get_contents('http://yourwebsite.com/index.php/controller/method'); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -