After following the instructions in the user guide, I am unable to run the test script via the command line.
My controller is located at /var/www/mysite/application/controllers/
class Tools extends CI_Controller { public function message($to = 'World') { echo "Hello {$to}!".PHP_EOL; } }
In the browser I can access
http://mysite/tools/message/ben
This function correctly outputs "Hello ben"
From the terminal, I should be able to run:
$ php index.php tool message "Ben"
My terminal should print out: "Hello Ben"
However, I get the following error:
PHP Fatal Error: Class 'CI_Controller' not found in /var/www/mysite/system/core/CodeIgniter.php line 233
My server is standard ubuntu LAMP. Codeigniter also comes standard and I have no problem running non-CI scripts via the command line.
My PHP is only installed in /usr/bin/php <-- This article hints at problems with running CI directly from usr/bin/php, however I am not using a shared PHP service and don't understand how this would Have an impact on how PHP executes CI scripts.
Thank you very much for your help in advance.
To resolve the error "Class 'CI_Controller' not found" try going to
Application -> Config -> database.php
and check the database details like hostname, username, password, and database.solved! (Part of the) problem is CodeIgniters error logging.
In application/config/config.php, I modified the following configuration properties:
This will disable logging and allow
$ php index.php
to execute.If anyone can explain why CI only shows this error on CLI PHP - it might help others who run into this issue and need to resolve it via error logging.