Command Line: IS_CLI - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Command Line: IS_CLI (/showthread.php?tid=42303) Pages:
1
2
|
Command Line: IS_CLI - El Forum - 06-02-2011 [eluser]Unknown[/eluser] Hi, I cannot find any information on the IS_CLI constant(?) described in the documentation at http://ellislab.com/codeigniter/user-guide/general/cli.html. Not super important but I would like to protect a controller from being accessed outside of CLI. Thanks! Command Line: IS_CLI - El Forum - 06-03-2011 [eluser]Seb[/eluser] Not sure about the IS_CLI, but you can use the indication given on http://ellislab.com/codeigniter/user-guide/libraries/input.html : Code: $this->input->is_cli_request() Command Line: IS_CLI - El Forum - 06-23-2011 [eluser]mrmeyers99[/eluser] Yeah, I think that the User Guide needs to be updated on this. It just says to use IS_CLI, but doesn't say what it is... Code: $this->input->is_cli_request() Command Line: IS_CLI - El Forum - 07-18-2011 [eluser]Unknown[/eluser] Forgive me for asking, I'm a newbie at Codeigniter. But where is the Code: $this->input->is_cli_request() Command Line: IS_CLI - El Forum - 07-19-2011 [eluser]Unknown[/eluser] /system/core/Input.php Command Line: IS_CLI - El Forum - 07-19-2011 [eluser]Seb[/eluser] No, you have to use it in your controller, if you want to check if the request is from command line (cli) or from a HTTP request. Command Line: IS_CLI - El Forum - 10-10-2012 [eluser]Tiến Thành[/eluser] [quote author="FarCoder" date="1314097510"]Hi, here is a use of this example: Code: public function cli() now if you access through CLI like: Code: php index.php yourcontroller cli Code: access from CLI otherwise if you visit this link through your browser you will get: Code: access is NOT from CLI Hope that explains it all.[/quote] I write a controllers Test.php with code: Code: <?php please help me to fix it. Command Line: IS_CLI - El Forum - 10-10-2012 [eluser]CroNiX[/eluser] 1) Your controller is supposed to extend CI_Controller, not Controller 2) You don't need to use get_instance() from within a controller (you do in a library or helper). The CI instance is already merged into $this in controllers. However this isn't working because of your error in #1. Command Line: IS_CLI - El Forum - 10-10-2012 [eluser]Tiến Thành[/eluser] May be My CI version is older so that i have to write Code: class Test extends CI_Controller{ , i can't use extends CI_Controller. Pls help me. Command Line: IS_CLI - El Forum - 10-10-2012 [eluser]CroNiX[/eluser] Well then input::is_cli_request() probably isn't in your version. It's in 2.x. Have you checked the docs that were included in the version you downloaded? The docs on the site are for the current version, 2.1.3. |