Is it possible to call a Codeigniter class function from an executable PHP file? I have a controller class and I want to call a function of that class from an executable PHP file.
Why? Because my application works with cronjobs. When I create a cronjob from the GUI, a new php file is created and set with the configuration to call the controller function.
How can I do it?
Edit:
I've tried this example, but It doesn't work. The cronjobs created are (combinations to test):
* * * * * /usr/bin/php /home/myweb/public_html/CI/application/controllers/tools message
* * * * * /usr/bin/php http://www.myweb.com/CI/site/index.php/tools/message
* * * * * /usr/bin/php index.php tools message
* * * * * php index.php tools message
But they don't work
Edit:
After the Ben's answer, I've tried (I have a site folder):
* * * * * /usr/bin/php /home/myweb/public_html/CI/index.php tools message
* * * * * /usr/bin/php /home/myweb/public_html/CI/site/index.php tools message
I obtain the next log errors:
ERROR - 2013-01-30 05:52:01 --> Severity: Notice --> Undefined index: REMOTE_ADDR /home/myweb/public_html/CI/system/core/Input.php 351
ERROR - 2013-01-30 05:52:01 --> Severity: Warning --> Cannot modify header information - headers already sent by (output started at /home/myweb/public_html/CI/system/core/Exceptions.php:185) /home/myweb/public_html/CI/system/libraries/Session.php 675
ERROR - 2013-01-30 05:52:01 --> Severity: Warning --> Cannot modify header information - headers already sent by (output started at /home/myweb/public_html/CI/system/core/Exceptions.php:185) /home/myweb/public_html/CI/system/helpers/url_helper.php 542
[Solved] I've solved it with curl:
* * * * * /usr/bin/curl http://www.myweb.com/CI/site/index.php/tools/message