gpt4 book ai didi

php - Cron 作业 - Codeigniter - 找不到类 'CI_Controller'

转载 作者:行者123 更新时间:2023-12-05 03:15:42 25 4
gpt4 key购买 nike

我正在尝试使用此命令在 cpanel 上创建一个 cron 作业:

/usr/bin/php -q /home/mystuff/public_html/application/controllers/scripts.php scripts release_reviews

我的scripts.php Controller 如下:

<?php

class Scripts extends CI_Controller
{
public function __construct()
{
parent::__construct();

if (!$this->input->is_cli_request()) show_error('Direct access is not allowed');

}

public function release_reviews()
{
echo release_reviews(); //where the actual logic will sit once the cron job works
}
}

当我尝试运行 cron 作业时得到的反馈: fatal error :在 /home/mystuff/public_html/application/controllers/scripts.php 中找不到类“CI_Controller”,第 3 行

我找不到任何证据表明任何人都遇到过与我相同的问题 - 大多数与此相关的主题与我的情况相同,而且显然效果很好。

提前致谢!

最佳答案

要通过命令行访问 CodeIgnter,您需要调用 index.php 文件,而不是您的 Controller 。

php /home/mystuff/public_html/index.php scripts release_reviews

文档:http://ellislab.com/codeigniter/user-guide/general/cli.html

关于php - Cron 作业 - Codeigniter - 找不到类 'CI_Controller',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13870716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com