I was wondering if oil can be uploaded to a directory on a hosted server and run as a cron job? More specifically I'm using Rackspace's cloud sites solution for a portion of my business and I'd like to be able to run cron jobs from there using tasks. Coming from codeigniter I could run commands from command line by just running the index.php and route to my class. Can this be done with FuelPHP?
I'm mostly asking to see if anyone else has experience. I'm also going to try to attempt this and if I hear no responses will update this post with the results.
It depends.
If you have commandline access, or access to a *real* cron, the answer is probably. If your server has some kind of control panel, again the answer is probably. Otherwise, no.
I say probably because PHP comes with different binaries, php, php-cgi and php-cli. In a normal compile and in most server distributions, all three are present. But I already heard horror stories of hosters that have only one online, and symlink the others to that one.
For oil you work you need it to be processed by php-cli. The others doen't work. Again, in a normal distro when you use 'php blah.php', the php binary knows that php-cli is needed, but doesn't know it's aliased to something else.
As of 1.2, oil will actually check, and will fail with an error if php-cli is not detected.
Alternatively you can use normal controller, and use a wget or other trigger mechanism to run them. You should add some security measures that make sure browsers can't request those URL's.
php-cli is not available.
It would seem the same 30 second time limit imposed on a HTTP based cron is intact with file_get_contents. Seems my scripts have to return in 30 seconds or less via HTTP to not timeout.
It looks like a command line based bootstrapper may be able to map command line arguments into a request parameter so one could call php index.php module/controller/method/param/param/param and enjoy the benefits of the framework from the command line. Am I missing something or should that be fairly straight forward?
That is not the problem, oil is written completely with the CLI in mind, it's basically a commandline Fuel interpreter (you can feed it Fuel code interactively).
Running tasks and other stuff is just one of the other features of it.
It's always a tradeoff when you design something, what sort of environments to take into account. And for FuelPHP we have decided we would require a resonable environment, like commandline access and PHP 5.3 support, and not hinder ourselfs by the odd constructions some cheap hosters come up with.
For a few bucks a month you can get a VPS with full access, there is no real reason anymore these days to give your money to the goDaddy's of this world...