Adam Jensen’s Blog: Cron tasks in Zend Framework apps

In his recent post Adam Jensen is presenting his approach to creating cron jobs in Zend Framework without having to load entire MVC infrastructure.

Now, any cron task we might envision will most likely need access to a fully-bootstrapped instance of the application; that way we’ll be able to use all of the framework’s usual development conveniences. However, loading the full MVC architecture is a bit of overkill, since we’re going to be performing the same basic sequence of tasks every time the script is hit (see Matthew Weier-O’Phinney’s recent discussion of service APIs for some other relevant concerns). So, we’re going to need a new application bootstrap and entry point, one that eschews the MVC routing and dispatch process in favor of something simpler. Essentially, all we’ll need is to be able to run an arbitrary collection of cron “task plugins,” the list of which can be configured in plain text via any of the various Zend_Config formats (e.g., the default application.ini file).

Adam’s solution is a “framework” or “environment” for developing and running cron jobs. He created cron service to handle execution of tasks, a cron job interface and a plugin infrastructure and shows us how to use it to write simple cron task.

  • Share/Bookmark