3
我在寻找一些帮助。我在codeigniter中有一个应用程序,我试图实现一个cron作业来自动化我的控制器中的一个方法来运行每个小时左右......Codeigniter Cron - “您找到的控制器/方法对未找到”
我在页面上有很多问题,但是我的错误“没有找到您请求的控制器/方法对。”
的Cron命令(从终端)是:PHP的index.php cron的索引
控制器(缩短我除去不涉及我的问题的其他方法。):
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;
}
}
控制器文件名是cron.php。如果我在浏览器中运行网址,它可以正常工作。如果我尝试使用终端,则会出现错误。我觉得我已经研究了一堆,并没有运气。我感谢任何帮助,我可以得到。我不确定你可能需要哪些其他信息来帮助我,但如果你问我,我会为你提供你需要的帮助。
CI 3+版本需要控制器和其他以'ucfirst'规则命名的类(例如Cron.php)。 – Tpojka
谢谢。我更改了文件名并确实解决了该问题。然而,现在我越来越“mysqli :: real_connect():(HY000/2002):连接被拒绝” 我已经尝试localhost和127.0.0.1主机名,也包括端口3306,仍然是相同的错误。对这个新错误有帮助吗? – khtims75
没关系,Tpojka,你的帮助确实解决了我的问题。这是我的错误,导致连接被拒绝。谢谢! – khtims75