【问题标题】:Codeigniter 2 restrict controller to command lineCodeigniter 2 将控制器限制为命令行
【发布时间】:2011-11-11 10:55:42
【问题描述】:

我需要将 CI 2 中的控制器限制为只能从命令行运行。应用程序中的其他控制器可从 Web 访问。

最好的方法是什么?

【问题讨论】:

    标签: php codeigniter command-line-interface


    【解决方案1】:

    您可能想查看if is a CLI request:

    class Mycontroller extends CI_Controller {
    
       function __construct()
       {
         parent::__construct();
    
         if(!$this->input->is_cli_request())
         { 
           // echo 'Not allowed';
           // exit();
         }
       }
    
    }
    

    【讨论】:

    • 真的很有帮助。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-14
    相关资源
    最近更新 更多