问题
I am using ZeroMQ socket library in my web application. I have configured php.ini so Apache can use ZMQ but I dont know how phpunit can use it.
Dont phpunit use the same php.ini which apache uses?
In phpunit I get following error.
PHP Fatal error: Class 'ZMQContext' not found in /home/idlecool/checker/testcases/checkerTest.php on line 53
回答1:
Which php.ini
file is used for Apache and command-line generally depends on your Linux distribution ; if using Debian or Ubuntu, you'll generally have :
/etc/php5/apache2/php.ini
for Apache- and
/etc/php5/cli/php.ini
for command-line -- and PHPUnit runs as a command-line application.
But note that quite often (it's true on Ubuntu, by default), all .ini
files from the /etc/php5/conf.d/
directory will be loaded in both Apache and CLI modes.
Which means that, if you want an extension to be loaded in both modes, you should create a .ini
file in that directory, loading and configuring it.
For example, you could have a /etc/php5/conf.d/zmq.ini
file, containing something like :
extension=zmq.so
(of course, you'll have to put the name of the right .so
file)
来源:https://stackoverflow.com/questions/9241210/php-an-external-class-library-is-accessible-from-apache-but-not-from-phpunit