doudang2537 2013-03-04 18:00
浏览 127
已采纳

Codeigniter命令行错误 - PHP致命错误:找不到类“CI_Controller”

After following the user guide instructions found here: http://ellislab.com/codeigniter/user-guide/general/cli.html I'm unable to run the test script via command line.

My controller located at /var/www/mysite/application/controllers/

    class Tools extends CI_Controller {

    public function message($to = 'World')
    {
        echo "Hello {$to}!".PHP_EOL;
    }
}

In my browser I can access

http://mysite/tools/message/ben

And the function correctly outputs "Hello ben"

From terminal I should be able to run:

$ php index.php tools message "Ben"

My terminal should print: "Hello Ben"

However I get the following error:

PHP Fatal error: Class 'CI_Controller' not found in /var/www/mysite/system/core/CodeIgniter.php on line 233

My server is pretty standard; ubuntu LAMP. Codeigniter is pretty standard too and I have no problem running non CI scripts via command line

My PHP binary is only located in /usr/bin/php <-- This post suggests an issue running CI directly from usr/bin/php, however I'm not operating a shared PHP service, and I don't see why this would make a difference to how PHP executes a CI script.

Any help or just an indication on how to debug this would be greatly appreciated.

Thanks in advance.

  • 写回答

5条回答 默认 最新

  • doushan1157 2013-03-28 18:52
    关注

    Solved! (partly) the issue was CodeIgniters error logging.

    In application/config/config.php, I modified the following config property:

    $config['log_threshold'] = 0;
    

    This disables logging, and allows $ php index.php to execute.

    If anyone can explain why CI only shows this error on CLI PHP - might help anyone else who has this issue and needs it resolved with error logging on.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!