2016-05-06 74 views
0
class Programmatic extends CI_Controller 
{ 

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

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

} 

這是我在CI中的示例類。 當我運行由PHP命令行:Codeigniter-php cli只能看__construct功能

php /my_path/index.php programmatic tester 

我的屏幕上,結果只有:

__construct

我試着輸入錯誤的函數名稱,例如tester2和CI給我一個錯誤:

ERROR: Not Found, The controller/method pair you requested was not found.

爲什麼當我運行我的命令時,屏幕上沒有看到「測試儀」?任何想法?

//編輯 - 我找到問題 這是我的掛鉤問題 - 我重定向到SSL(https)。現在我有一個例外 - 如果它是cli_request,它不會重定向到https。

+0

如果您使用笨3檢查文件名也有第一個字母大寫。 – user4419336

+0

我安裝了新的默認CI版本,它可以工作。所以我認爲我的CI配置有問題 - 但我不知道它是什麼。 –

回答

0

試試這個

$ cd /Users/MyUsername/Sites/code 

php index.php controler method 

php index.php/controller/function/param1/ 
+0

未正常工作:PHP致命錯誤:未找到類「CI_Controller」。 –

+0

我試了兩個版本。沒有工作。 –

0

在Windows中打開Run > "cmd"並導航到你的笨項目。

$ cd /path/to/project; - >您需要更改並轉到此項目文件夾。

$ php index.php programmatic tester

如果你做的沒錯,你應該看到

Result:
__construct
tester

參考鏈接:http://www.codeigniter.com/user_guide/general/cli.html 問候:

+0

您的鏈接已過時。 Ellislab不再處理codeigniter請更新從這裏http://www.codeigniter.com/docs的鏈接,你會發現ci2和ci3的用戶指南 – user4419336

+0

我已更新給定的鏈接。 –