I am trying to figure out how to make a Zend Framework script to run as a cronjob from a command line, but the bootstrap setup below seems to fail:
define('BASE_PATH', realpath(dirname(__FILE__) . '/../') . '/');
define('APPLICATION_PATH', BASE_PATH . 'application/');
define('APPLICATION_ENV', 'live');
// Ensure library/ is on include_path
set_include_path(
implode(PATH_SEPARATOR, array(
realpath(BASE_PATH . 'library'),
realpath('/usr/src/ZendFramework-1.12.3/library')
) // closes array
) // closes implode
. get_include_path()
);
require_once 'Zend/Application.php';
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
// Load only the ressources that you need
$application->getBootstrap()->bootstrap(array('db', 'mail'));
It fails on the $application->getBootstrap()->bootstrap(array('db', 'mail'))
line. I am puzzled. It seems to be able to access frontController
module, but neither db
or mail
modules works. Any ideas what it could be?
Edit: Below are the error details:
Fatal error: Uncaught exception 'Zend_Application_Bootstrap_Exception' with message 'Resource matching "db" not found' in /usr/src/ZendFramework-1.12.3/library/Zend/Application/Bootstrap/BootstrapAbstract.php:694
Stack trace:
#0 /usr/src/ZendFramework-1.12.3/library/Zend/Application/Bootstrap/BootstrapAbstract.php(632): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('db')
#1 /usr/src/ZendFramework-1.12.3/library/Zend/Application/Bootstrap/BootstrapAbstract.php(586): Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap(Array)
#2 /www/.../live/htdocs/v2/cron/bootstrap.php(26): Zend_Application_Bootstrap_BootstrapAbstract->bootstrap(Array)
#3 /www/.../live/htdocs/v2/cron/send-leads.php(2): require_once('/www/...')
#4 {main}
thrown in /usr/src/ZendFramework-1.12.3/library/Zend/Application/Bootstrap/BootstrapAbstract.php on line 694