Title pretty much sums it up. I’d like to write a script to import some data from a third party. Is there any way I can get either an instance of CodeIgniter’s Active Record class, or of a particular model inside of an a script that can be run from the command line?
Share
Say you have your CodeIgnited application inside
ignited/, you have your command line script running incli/. Here is your folder layout:Now you want
cli/mycli.phpto use some model fromignited/First, you should do something with your
ignitedapp:Modify your default controller (which is set in
ignited/application/config/routes.php). For exampleignited/application/controllers/welcome.php:add these code:
so it would look like:
For testing, I created a test model
ignited/application/models/do_nothing_model.php:OK! Now try this in
cli/mycli.php:Drawback: unable to run the default action of your default controller in command line
UPDATE 2012-06-08: from CodeIgniter Wiki