2

I have MAMP on my machine, and I would like to install memcache for php, because one of my project throws errors like Fatal error: Class 'Memcache' not found.

I installed X-Code from appstore, and libevent, memcached, libmemcached with homebrew.

Then..

cd /tmp; pecl download memcached
gzip -d < memcached-2.2.0.tgz | tar -xvf -
cd memcached-2.2.0; phpize
./configure; make
sudo make install

Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20100525/

After that I copied memcached.so and memcache.so to my extension_folder:

/Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20121212/

and added extension = memcached.so to my php.ini.

I still get fatal error.. what's the problem?

2

It seems there are 2 memcache extensions. There is memcached and memcache the latter one does not seem to be maintained anymore last stable from 2012.

It looks like your code depends on Memcache since you are using brew, you could just do:

brew install php55-memcache

or

pecl install 

Install brew by issuing:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
1

Looks at the dates mentioned in the folder structure. Those dates are really the API version. The API from 2010 isn't compatible with the API from 2012.

You will need to compile the PHP memcache extension using the phpize, etc. from the actual version of PHP you're going to use. It sounds like you have two different PHP installations - one in /usr/lib/php and one in /Applications/MAMP/.

  • I tried with /Applications/MAMP/bin/php/php5.5.10/bin/phpize, but the problem is same. I also add the extension=memcached.so and extension=memcache.so lines to php ini, and copied these files to extension_dir. Memcached is running in the background. – EmilyR1 May 20 '14 at 9:26
  • 1
    Do not copy over the extensions from the directory with the different date - it will never work. The easiest way to proceed is to delete the directory you have with the memcache code from PECL and start over from scratch using the correct phpize. If you have once "polluted" the directory with the wrong information, you will have to "make clean" to clean everything up - the easiest way to ensure you do that, if you do not know your way around programming and makefiles, is to simply remove the folder and start over. – jksoegaard May 20 '14 at 10:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .