Steve Claridge Steve Claridge - 4 years ago 120
PHP Question

Memcached installed but class not found

If I run phpinfo() it tells me that memcached is installed.

memcached
memcached support enabled
Version 1.0.2
libmemcached version 0.44
Session support yes
igbinary support no


I installed it with
sudo pecl install memcached


But when I try to instantiate the memcached class it is not found:

$mc = new Memcached();

gets:

Fatal error: Class 'Memcached' not found

Never used PECL as an install mechanism before, do I need to do something extra in php.ini or somewhere to be able to use the class?

Answer Source

It's possible that it didn't install correctly or, as you say, you might need to add the following to php.ini: extension = memcached.so

But since you say it shows up in phpinfo() it seems more likely that it just didn't install correctly. Were there any errors in the output during installation?

Also, to state the obvious, make sure you've restarted your server.

I wrote up a tutorial on getting memcached running on Ubuntu, which I mention not to self-promote, but just in case it's helpful.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download