2

I have a local WP site that depends on Memcached. The readme says "Use memcached and the PECL memcache extension to provide a backing store for the WordPress object cache."

As a far as I can tell, my config meets those requirements. But when I attempt to access the application, I get:

Fatal error: Uncaught Error: Class 'Memcache' not found in. . .

I'm running php 7.3 installed via Homebrew, and Memcached 3.1.3, installed via PECL. Memcached 3.1.3 says it's compatible with php 7.3, and I followed these instructions to add Memcache as an extension to my php server. If I start php via Homebrew, I can see the Memcache process when I run ps -ef | grep -i memcached, and the config appears when I run php --info | grep memcached\\. But, I can't connect to Memcached through my Valet app or through Telnet.

If I run Memcached through Homebrew, I get a different version, 1.5.13, which I think predates php 7.3. As I understand Homebrew only installs stable releases. When the Homebrew Memcache is running I can connect via Telnet, but not through the Valet app.

What's different about the Homebrew install of Memcached? I assume Homebrew must somehow make Memcache externally accessible but I don't know what's going on behind the scenes.

jamesfacts
  • 371
  • 2
  • 14

1 Answers1

2

Worked for me:

brew install libmemcached
brew install pkg-config
pecl install memcached

Push Enter to all question

Then:

cd /usr/local/etc/php/7.3
sudo vim php.ini
[memcached]
extension=/usr/local/Cellar/php/7.3.5/pecl/20180731/memcached.so

Replace path parts accordingly to your system

Finally:

brew services restart php
php -m
subdesign
  • 181
  • 1
  • 2
  • 11
  • 1
    There was an error for zlib dir. I have passed that zlib path when while installing the`pecl install memcached` installation done successfully. Thanks your solution worked. – Harish Patel Jun 14 '22 at 03:59