Codeigniter 2将控制器限制到命令行 [英] Codeigniter 2 restrict controller to command line
本文介绍了Codeigniter 2将控制器限制到命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要限制CI 2中的控制器仅从命令行运行。应用程序中的其他控制器可从Web访问。
I need to restrict a controller in CI 2 to only run from command line. The other controllers in the application are accessible from the web.
这是最好的方法是什么?
What's the best way to do it?
推荐答案
希望检查是否为CLI请求:
class Mycontroller extends CI_Controller {
function __construct()
{
parent::__construct();
if(!$this->input->is_cli_request())
{
// echo 'Not allowed';
// exit();
}
}
}
这篇关于Codeigniter 2将控制器限制到命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文