applechief
applechief

Reputation: 6915

Codeigniter 2 restrict controller to command line

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?

Upvotes: 8

Views: 4752

Answers (1)

Damien Pirsy
Damien Pirsy

Reputation: 25445

You might want to check if is a CLI request:

class Mycontroller extends CI_Controller {

   function __construct()
   {
     parent::__construct();

     if(!$this->input->is_cli_request())
     { 
       // echo 'Not allowed';
       // exit();
     }
   }

}

Upvotes: 18

Related Questions