【问题标题】:Codeigniter - php cli see only __construct functionCodeigniter - php cli 只能看到 __construct 函数
【发布时间】:2016-05-06 11:10:27
【问题描述】:
class Programmatic extends CI_Controller
{

    public function __construct()
    {
        parent::__construct();
        echo '__construct'.PHP_EOL;
    }

    public function tester()
    {
        echo 'tester';
    }

}

这是我在 CI 中的示例课程。 当我通过命令行运行 php 时:

php /my_path/index.php programmatic tester

我屏幕上的结果只有:

__构造

我尝试输入错误的函数名,例如tester2 和 CI 给我一个错误:

错误:未找到,未找到您请求的控制器/方法对。

为什么我在运行命令时没有在屏幕上看到“tester”?有什么想法吗?

// 编辑 - 我发现问题 这是我的钩子的问题 - 我已重定向到 SSL (https)。现在我有一个例外 - 如果是 cli_request 它没有重定向到 https。

【问题讨论】:

  • 如果您使用 codeigniter 3,请检查您的文件名是否包含首字母大写。
  • 我安装了新的默认 CI 版本,它可以工作。所以我认为我的 CI 配置有问题 - 但我不知道是什么问题。

标签: php codeigniter codeigniter-3


【解决方案1】:

试试这个

$ cd /Users/MyUsername/Sites/code

php index.php controler method

 php index.php/controller/function/param1/

【讨论】:

  • 无法正常工作:PHP 致命错误:找不到类“CI_Controller”。
【解决方案2】:

在 Windows 中打开 Run > "cmd" 并导航到您的 CodeIgniter 项目。

$ cd /path/to/project; -> 您需要更改并转到此项目文件夹。

$ php index.php programmatic tester

如果你做对了,你应该会看到

结果:
__construct
测试员

参考链接:http://www.codeigniter.com/user_guide/general/cli.html 问候:

【讨论】:

  • 您的链接已过期。 Ellislab 不再处理 codeigniter 请从这里更新链接 codeigniter.com/docs 您将找到 ci2 和 ci3 的用户指南
猜你喜欢
  • 2013-07-22
  • 2023-03-22
  • 1970-01-01
  • 1970-01-01
  • 2016-10-22
  • 2011-08-30
  • 1970-01-01
相关资源
最近更新 更多