Memcache & php: Fatal error: Class 'Memcache' not found in

I found some very similar questions. However, each of them indicates the use of the wrong php.ini file or memcache is not installed at all or has memcached, and not memcache settings, etc. Therefore, I think this problem is different, despite the fact that searching for this Errors cause some discussion.

Anyway, when I try to instantiate a new Memcache object, I get:

Fatal error: Class 'Memcache' not found in /websites/../app/app_controller.php on line 360

Since debugging files from the command line can sometimes give you bad information, I just added debugging to the pages:

<pre> <?= system('php -i | grep "php.ini"') ?> <?= system('php -i | grep memcache') ?> <?= system('php -i | grep extension_dir') ?> </pre> 

This gives me:

 Configuration File (php.ini) Path => /etc Loaded Configuration File => /private/etc/php.ini memcache memcache support => enabled memcache.allow_failover => 1 => 1 memcache.chunk_size => 8192 => 8192 memcache.default_port => 11211 => 11211 memcache.default_timeout_ms => 1000 => 1000 memcache.hash_function => crc32 => crc32 memcache.hash_strategy => standard => standard memcache.max_failover_attempts => 20 => 20 Registered save handlers => files user sqlite memcache Registered save handlers => files user sqlite memcache extension_dir => /usr/local/php53/modules => /usr/local/php53/modules 

The memcache report tells me that I correctly configured the php.ini file and memcache.so file in the right place, but this information should be clear:

 extension_dir = "/usr/local/php53/modules" extension=memcache.so 

and memcache.so is:

 younker % la /usr/local/php53/modules/memcache.so -rwxr-xr-x 1 younker staff 60196 Feb 14 10:56 /usr/local/php53/modules/memcache.so 

So, I obviously missed something, I just don't know why php cannot find the Memcache class.

+4
source share
3 answers

This discussion died down, so I wanted to publish my fix (which I just wrapped up).

Basically, I stopped using the apache / php compilation that was sent with my os (mac osX 10.5.3) and reinstalled. I tried homebrew first, but got a bunch of errors when trying to install wget, and then again when trying to install justin hileman php formula . Therefore, by uninstalling macports as part of the homebrew troubleshooting process, I reinstalled macports and installed everything. however macports sucks and improperly installed php with mysql support, so I just grabbed the php binary I wanted and installed the old way using the following configuration options:

 --prefix=/opt/local --with-mysql=/usr/local/mysql --enable-memcache --mandir=/opt/local/share/man --infodir=/opt/local/share/info --with-config-file-path=/opt/local/etc/php5 --with-config-file-scan-dir=/opt/local/var/db/php5 --disable-all --enable-bcmath --enable-ctype --enable-dom --enable-fileinfo --enable-filter --enable-hash --enable-json --enable-libxml --enable-pdo --enable-phar --enable-session --enable-simplexml --enable-tokenizer --enable-xml --enable-xmlreader --enable-xmlwriter --with-bz2=/opt/local --with-mhash=/opt/local --with-pcre-regex=/opt/local --with-readline=/opt/local --with-libxml-dir=/opt/local --with-zlib=/opt/local --disable-cgi --with-apxs2=/opt/local/apache2/bin/apxs --with-pear=/opt/local/lib/php --with-openssl=/opt/local 

At this moment, all puppies and rainbows.

+4
source

Oki, so the memcache module is loaded, but what about the enable path? the error tells you that it cannot find the memcache class, so take a look at the get_include_path and set_include_path functions and where the memcache class file is located. From the views, I assume that you application re-sets the include path, but does not support the default include path from php.ini when it should also keep the old path. smth like this:

 <?php $path = '/some/app/include/path'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); ?> 
+3
source

Using:

 sudo a2enmod memcache 

or similar.

+2
source

Source: https://habr.com/ru/post/1339741/


All Articles