khtims75
khtims75

Reputation: 81

Codeigniter Cron - "The controller/method pair you requested was not found"

I am looking for a bit of help. I have an app in codeigniter that I'm trying to implement a cron job to automate a method in my controller to run every hour or so...

I have a ton of code on the page in question but my error is "The controller/method pair you requested was not found."

Cron command (from terminal) is: php index.php cron index

Controller (shortened. I removed the other methods not involved with my question):

include('application/libraries/Twilio.php');
require_once 'application/third_party/Infusionsoft/infusionsoft.php';

class Cron extends CI_Controller{

public $pagination_config;
public $total_rows;
private $users_table_name;
private $review_sites_table_name;
private $ci;
public $customer_reviews_info;

function __construct() {
    parent::__construct();
    $this->ci = & get_instance();
    $this->load->database();
    $this->load->helper('url');
    $this->load->helper(array('form', 'url'));
    $this->load->helper('security');
    $this->load->library('form_validation');
    $this->load->library('pagination');
    $this->load->library('tank_auth');
    $this->lang->load('tank_auth');
    $this->load->model('CronModel');
    $this->load->library('simple_html_dom');
    $this->load->config('twilio', TRUE);

    $this->AccountSid = $this->config->item('account_sid', 'twilio');
    $this->AuthToken = $this->config->item('auth_token', 'twilio');

    $this->users_table_name = $this->ci->config->item('users_table_name', 'tank_auth');
    $this->review_sites_table_name = $this->ci->config->item('review_sites_table_name', 'tank_auth');
    $this->customer_reviews_info = $this->ci->config->item('customer_reviews_info', 'tank_auth');
}

  public function index()
  {
    echo "Hello, World" . PHP_EOL;
  }

}

The controller file name is cron.php. If I run the url in a browser it works fine. If I try to use the terminal I get the error. I feel I've researched a bunch and have not had any luck. I appreciate any help I can get. I'm not sure what other information you might need to help me but if you ask I will get you what you need to help me.

Upvotes: 3

Views: 7315

Answers (1)

Tpojka
Tpojka

Reputation: 7111

CI 3+ version needs controllers and other classes named by ucfirst() rule (e.g. Cron.php). Docs.

Upvotes: 2

Related Questions