My app is working from the web side of things.
I’d like to get the CLI working so that I can run unit tests and the such
Here’s what I have for a test script:
$pthRoot = dirname(__FILE__);
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/..'));
define('APPLICATION_ENV', 'development');
define('SERVER_ROLE', 'development');
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library') . PATH_SEPARATOR . realpath($pthRoot . '/../controllers')
. PATH_SEPARATOR . get_include_path()
)));
date_default_timezone_set('America/Toronto');
require_once('Zend/Loader/Autoloader.php');
$autoloader = Zend_Loader_Autoloader::getInstance();
require '../bootstrap.php';
require_once 'Zend/Application.php';
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$_SERVER['SERVER_ROLE'] = 'development';
$bootstrap = $application->getBootstrap();
$bootstrap->runScript();
$db = Zend_Registry::get('db');
$sql = "select * from settings";
print_r($db->fetchAll($sql));
Unfortunately, I get an error at the get(‘db’) line.
PHP Fatal error: Uncaught exception ‘Zend_Db_Adapter_Exception’ with message ‘The mysql driver is not currently installed’
According to phpinfo from the command line, the mysql driver is running. What am I missing?
Thanks in advance.
If you are using a MySQL Adapter with Zend Framework, you have two possibilities (I quote the doc) :
Which one of those are you trying to use ?
If it’s the first one, is the extension pdo_mysql activated for CLI ?
(you can use “php -m” to get the list of extensions that are loaded)
If it’s the second one, is the extension mysqli activated for CLI ?
It seems none of the two adapter are using the extension mysql (which is quite old) ; so, if this one appears, it’s probably not really relevant.
With a bit of luck, it’ll just be that “the right extension” is loaded in the php.ini file used for Web, and not in the one used for CLI…