I have installed the memcached and loaded the memcached extension, but when I was runnning a test with PHPUnit, it told class memcached not found. Can anyone tell me why, and how to solve it?
For me the problem was I had two different php versions installed on my machine. One was with Memcached installed and the other was not. I just ran:
$ whereis php
And it listed the paths of the two php installations. Then I found which had the Memcached installed by executing:
$ /usr/bin/php -i | grep memcache
$ /usr/local/bin/php -i | grep memcache
If none of these return any matches, and you are sure you have Memcached installed, then you are using wrong php.ini as above comments suggested. You can try starting php with -c option, to specify the path to the php.ini:
$ /usr/bin/php -c /etc/php5/cli/php.ini
Then it was just a matter of using the correct php path when executing the unit tests:
$ /usr/bin/php vendor/bin/phpunit tests
Oh, and please note that there are two separate extensions - one is called "Memcache", and the other is "Memcached". If you installed one of it, and try to use the other, it won't work for obvious reasons.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With