Reputation: 648
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.
Upvotes: 0
Views: 3236
Reputation: 137
You can copy the pdo_mysql.so
extention of Zend Server to you php-cli
extension folder and the pdo_mysql.ini
file of Zend Server to the ini folder of php-cli
.
Upvotes: 1
Reputation: 1528
To get PHP CLI working on Zend Server try this from https://serverfault.com/questions/356775/how-to-install-php-cli-with-pnctl-alongside-zend-server
Extend your $PATH:
export PATH=$PATH:/usr/local/zend/bin:/usr/local/zend/sbin
Or more permanently:
cat >> $HOME/.bashrc <<EOF
export PATH=$PATH:/usr/local/zend/bin:/usr/local/zend/sbin
EOF
reboot
Upvotes: 0
Reputation:
When running Zend Server, you have to source /etc/zce.rc
to get the php cli working, if the command is not in your profile:
$ . /etc/zce.rc
Upvotes: 0
Reputation: 401032
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...
Upvotes: 1