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

查看:37
本文介绍了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 工具消息奔"

$ php index.php tools message "Ben"

我的终端应该打印:Hello Ben"

My terminal should print: "Hello Ben"

但是我收到以下错误:

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 灯.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 <-- 这篇文章 提出了直接从 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.

任何帮助或只是关于如何调试的指示将不胜感激.

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

提前致谢.

推荐答案

已解决!(部分)问题是 CodeIgniters 错误记录.

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

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

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天全站免登陆