Loading Zend Config file for a Cron Job
The other day I talked about using Apache Environment variables to determine which section of a config file to use for a Zend Framework website. That works swimmingly, however, I had a cron job that was running for the same site, and since it was piped directly to php, Apache Environment variables were not an option. Fortunately, PHP has the function php_uname(’n') which will output the hostname of the computer. You can then load the appropriate config section based on that:
<?php
$environment = (php_uname(‘n’) == ‘rlbolton-desktop’) ? ‘development’ : ‘production’;
$config = new Zend_Config_Ini(APP_PATH . ‘configs/config.ini’, $environment);
?>