How to resolve class ‘memcached’ not found in laravel

how to resolve class memcached not found

After installing the memcached on the server or local machine, we can use memcached functionalities. But sometimes we may get an error like class ‘memcached’ not found. So here i will give the possible solution to resolve class ‘memcached’ not found.

So in the resolution of this error first thing we should to check whether memcached is installed on your machine or not. If it is already installed then you can move to the next thing to check, otherwise you can run the following command to install the memcached on your ubuntu machine.

Install Memcached

sudo apt-get install memcached

Next thins which you should to check is whether php extension of memcached is installed or not. After installing memcached on machine we need php extension to use the memcached features in laravel or other php frameworks.

Install Memcached Extension

You can run the ubuntu command below in your terminal to install memcached php extension.

sudo apt-get install php-memcached

or specific version for specific php version like below-

sudo apt-get install php7.3-memcached
or
sudo apt-get install php7.4-memcached

If you are using wampp or xampp server on windows machine, you will need to remove semi colon infront of memcached extension  like below-

;extension=php_memcache.dll

to

extension=php_memcache.dll

After doing the above thing, definitely you will need to restart the apache server. So don’t forget to restart apache.