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?
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'
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With