I’ve had this weird problem developing PHP Memcache these days. The Memcache environment was installed successfully but the running code always reported an error
$mem = new Memcache();
$mem->connect('127.0.0.1',11211);
$mem->set("foo","3",0,10);
echo $mem->get("foo");
Running tips PHP Fatal error: Class ‘Memcache’ not found in/Users/XXXXXXXXX/demo/index. The PHP on line 9
Finally, using baidu, Google and their own various experiments finally found the cause of the problem:
code did not find the corresponding memcache.so file
1, install memcache
brew search memcache
Find memcache (note: not memcached) that corresponds to the PHP version installed on your computer.
is installed using brew
brew install php56-memcache
When the installation is complete, the php56-memcache installation directory will be viewed
2, configure php.ini
add at the end of php.ini
extension_dir = /usr/local/Cellar/php56-memcache/2.2.7
extension = memcached.so
Finally, rerun it, and you’ll see the magic: it worked
Read More:
- [Solved] PHP Fatal error: Uncaught Error: Class ‘Redis‘ not found in
- Mac installs the php Swoole extension and appears Enable openssl support, require openssl library or fatal error:’openssl/ssl.h’ file not found
- [Solved] Fatal error: Class ‘think\Container‘ not found & [InvalidArgumentException] Could not find package
- [Solved] Fatal error: Uncaught Error: Class ‘Imagick‘ not found
- PHP error in Windows: class’ mysqli ‘not found
- laravel The Process class relies on proc_open, which is not available on your PHP installation.
- PHP Error Object of class mysqli could not be converted to string in
- Mac: Where is php.ini Location
- [Solved] PHP Fatal error: Uncaught Elasticsearch\Common\Exceptions\NoNodesAvailableException: No alive nodes
- How to Solve PHP Error: no package’oniguruma’ found
- [Solved] Laravel admin Error: Symfony\Component\Debug\Exception\FatalThrowableError : Class ‘Doctrine\DBAL\Driver\PDOMySql\Driver’ not found
- [Solved] WordPress Upgrade PHP 5.6 to 7.x Fatal error: Uncaught Error: Call to undefined function mysql_connect()
- Error during session start; please check your PHP and/or webserver log file and configure your PHP
- [PHP] php8 jit does not support 32-bit systems WARNING: JIT not supported by host architecture
- How to Solve PHP Fatal error: Namespace declaration statement has to be the very first statement
- PHP php-config is not installed error in ubuntu 16 [How to Solve]
- Error while injecting dependencies into App\Controller\IndexController: No entry or class found for
- composer Error: The requested PHP extension ext-bcmath * is missing from your system. Install or enable
- [Solved] PostgreSQL configure: error: readline library not found
- PHP encryption 3DES error Call to undefined function: mcrypt_module_open() solution