Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Codeigniter via CLI outputs website root instead of expected result

I'm following this tutorial on running Codeigniter via the CLI. I've done everything they've done (copied and pasted) now when I run this command, it doesn't do what is expected except it outputs the website index contents.

$ cd /Users/MyUsername/Sites/code
$ php index.php tools message

The output I get is the index page HTML source, e.g. http://localhost/code.

The expected result should be

Hello World!

How can I achieve this to make it work?

like image 728
MacMac Avatar asked Oct 06 '11 16:10

MacMac


3 Answers

try this:

php index.php/controller/function/param1/param2/param3 etc

or

php index.php controller function param1 param2 param3 etc

also, post the content of your $_SERVER var and value of the 'uri_protocol' variable from config.php.

$config['uri_protocol'] should be 'AUTO'

like image 95
Vlad Balmos Avatar answered Nov 11 '22 03:11

Vlad Balmos


For me this was resolved by changing:

$config['uri_protocol'] = 'AUTO' 

in the main config file.

I had previously changed it to

'REQUEST_URI'

which doesn't work with CLI apparently.

like image 29
Victor Schelin Avatar answered Nov 11 '22 03:11

Victor Schelin


The output I get is the index page HTML source, e.g. http://localhost/code.

You have got an error with your routing, your new example CLI controller is not fired, but another controller. Which error you have with your routing is hard to say, as you have not shown your whole code.

like image 32
hakre Avatar answered Nov 11 '22 02:11

hakre