Search code examples
laravellaravel-5memcachedphp-7pecl

Laravel 5.2 - Memcache with PHP7 - Class Memcache does not exist


I have recently upgraded the server to PHP7 (L5.2) and having trouble with Memcache. The error message is Class Memcache does not exist. I already have installed Memcached PECL but seems like it doesn't go well with PHP7. What is the best alternative solution to get it worked?


Solution

  • At the moment I was installing memcached for PHP7 it was not finished as stable for PHP7. But here is the way to build it using commands:

    yum install libmemcached-devel
    wget https://github.com/php-memcached-dev/php-memcached/archive/php7.zip -O php-memcached-php7.zip
    unzip php-memcached-php7.zip
    cd php-memcached-php7
    phpize
    ./configure
    make
    make install
    echo 'extension=memcached.so' >> /etc/php.ini
    

    This script is for CentOS 7, but generally it should work everywhere, with minor changes