Running CI without a web server (e.g., for cron scripts or unit tests) |
[eluser]Unknown[/eluser]
I've created a little script which bootstraps the CI superobject and loader, allowing one to use CI outside a cgi/mod_php context and without a Controller object. This has been especially handy for cronjobs and unit tests. Since I take a different, more direct approach than what I saw on the wiki, I've posed my code here. Note that my approach does not require a web server or even php-cgi at all. To use it, modify the CI_REALBASE constant and $system_folder and $application_folder variables to point to your real CI install. Then simply require_once the fake-codeigniter.php file at the top of your script, then use get_instance() to access and start using the CI superobject. Additional notes: * The script assumes the use of PHP5. PHP4 will require modifications (you'll have to check the php version and load Base4 instead of Base5). * As little as possible is loaded, and the autoloader is not run, so you will have to load a lot of things yourself. * This was written for CI 1.6.3, but will probably work with 1.7.0 with little or no modification. * It makes some simplifying assumptions, so you may have to tweak things further if you have an unusual install. Code: <?php |
Messages In This Thread |
Running CI without a web server (e.g., for cron scripts or unit tests) - by El Forum - 01-20-2009, 09:34 AM
Running CI without a web server (e.g., for cron scripts or unit tests) - by El Forum - 01-21-2009, 07:07 AM
Running CI without a web server (e.g., for cron scripts or unit tests) - by El Forum - 01-21-2009, 07:49 AM
Running CI without a web server (e.g., for cron scripts or unit tests) - by El Forum - 01-23-2009, 12:11 PM
Running CI without a web server (e.g., for cron scripts or unit tests) - by El Forum - 07-31-2010, 05:47 AM
|