Codeigniter命令行错误 - PHP致命错误:未找到类'CI_Controller' [英] Codeigniter Command line error - PHP Fatal error: Class 'CI_Controller' not found

查看:1927
本文介绍了Codeigniter命令行错误 - PHP致命错误:未找到类'CI_Controller'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照此处的用户指南说明操作: http://ellislab.com /codeigniter/user-guide/general/cli.html 我无法通过命令行运行测试脚本。

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.

我的控制器位于/ var / www / mysite / application / controllers /

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

并且函数正确地输出Hello ben

And the function correctly outputs "Hello ben"

从终端,我应该能够运行:

From terminal I should be able to run:


$ php index.php工具讯息「Ben」

$ php index.php tools message "Ben"

print:Hello Ben

My terminal should print: "Hello Ben"

但是,我收到以下错误:

However I get the following error:


PHP致命错误:在第233行的/var/www/mysite/system/core/CodeIgniter.php中找不到类'CI_Controller'

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

我的服务器是很标准; ubuntu LAMP。 Codeigniter也很标准,我没有问题通过命令行运行非CI脚本

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

我的PHP二进制文件只位于/ usr / bin / php < a href =http://stackoverflow.com/questions/10322587/codeigniter-command-line-cron-cpanel/11156257#11156257>此帖子建议直接从usr / bin / php运行CI的问题,但是我没有运行共享的PHP服务,我不明白为什么这将导致PHP执行一个CI脚本。

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.

任何帮助或只是

提前感谢。

推荐答案

解决了! (部分)问题是CodeIgniters错误日志。

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

在application / config / config.php中,我修改了以下config属性:

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

$config['log_threshold'] = 0;

这将禁用日志记录,并允许 $ php index.php 执行。

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

如果任何人都能解释为什么CI只在CLI上显示这个错误PHP - 可能会帮助任何人谁有这个问题,需要它解决与错误日志

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.

这篇关于Codeigniter命令行错误 - PHP致命错误:未找到类'CI_Controller'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆