Skip to content

CI on the command line

World Wide Web Server edited this page Jul 4, 2012 · 12 revisions

I have been working on a few random things in spare time at work, one of them is getting CI to work on the command line. Getting it to accept parameters was much easier than I expected, all it requires is a simple extension to the URI class.

[h3]Download[/h3] File:MY_URI.zip

[h3]Installation[/h3]

Copy the file to application/libraries/

[h3]Set-up[/h3]

In your config, set one of the following values for uri_protocol.

[code]$config['uri_protocol'] = "AUTO"; // Works for web and command line $config['uri_protocol'] = "CLI"; // Command line only[/code]

Or to have it working on web with a specific uri type and command line at the same time, change path info to any of the normal CI uri types.

[code]$config['uri_protocol'] = isset($_SERVER['REQUEST_URI']) ? 'PATH_INFO' : 'CLI';[/code]

cd into your CI set-up and run index.php like below.

[quote]php index.php controller method param1 etc[/quote]

Clone this wiki locally