Bruno Mota
Bruno Mota

Reputation: 111

How to install Memcached on Xampp Mac

I need to use Memcached in XAMPP because I need to develop locally, and all solutions i've seen so far, dont work.

Fatal error: Class 'Memcached' not found in /Applications/XAMPP/xamppfiles/htdocs/system/libraries/Session/drivers/Session_memcached_driver.php on line 108
A PHP Error was encountered

Severity: Error

Message: Class 'Memcached' not found

Filename: drivers/Session_memcached_driver.php

Line Number: 108

Backtrace:


//does not work, and actually i need this not the bottom one.
//keep in mind that the service is running, and everything was succesfully
//installed with brew

$this->_memcached = new Memcached();


//works
$this->_memcached = new Memcache;

Upvotes: 2

Views: 4219

Answers (2)

M Polak
M Polak

Reputation: 877

This is what worked for me:

  1. Install libmemcached with brew:

    brew install libmemcached

  2. Install memcached with pecl:

    • sudo /Applications/XAMPP/xamppfiles/bin/pecl install memcached

    • When prompted for the libmemcached directory, press 'Enter' and the installer will automatically find it.
  3. Add the memcached extension to your php.ini file:

    • sudo vim /Applications/XAMPP/xamppfiles/etc/php.ini

    • Add 'extension=memcached.so' to the file
  4. Restart your Apache server (either use the GUI or run):

    sudo apachectl restart

  5. Start memcached with brew:

    brew services start memcached

Created a gist with these instructions.

Upvotes: 4

Bruno Mota
Bruno Mota

Reputation: 111

Found the solution :)

brew install libevent
brew install autoconf
brew install libmemcached

//Download the PHP version you are using and past it to:
cd /Applications/MAMP/bin/php/php5.6.7/include/php

//Configure the source with
/Applications/MAMP/bin/php/php5.6.7/include/php/configure

//go to
cd /Applications/MAMP/bin/php/php5.6.7/bin

//compile memcached
./pecl install memcached

//go back
cd ../

//Add the memcached.so extension to your php.ini file
echo -e "\n[memcached]\nextension=memcached.so" >> conf/php.ini

//start memcached server
memcached -m 24 -p 11211 -d

//restart MAMPP and thats it!

Upvotes: 2

Related Questions