Class Memcached Not Found Lumen 5.4

When trying to run artisan commands, the following error appears

[Symfony\Component\Debug\Exception\FatalThrowableError] Class 'Memcached' not found 

I recently worked on another project that used Lumen 5.3 and had no problems running artisan commands. Both projects are located on the same virtual field, and in addition to Lumen versions, there are no differences in server settings.

I checked that Memcached is running and there are no problems.

I tried dump-autoload build by deleting the provider folder and reinstalling, but none of them changed the situation.

I would prefer not to go back to 5.3, if possible.

Is there any way to solve this problem?

+6
source share
5 answers

There was the same problem. Check if the memcached extension is installed for your version of php, and also check if it is configured correctly in the php.ini file (it may look in the wrong directory).

+7
source

It looks like your memcahed is not installed or incorrectly configured.

for a quick fix

use file cache driver instead of memcached

 CACHE_DRIVER=file 
+6
source

Ubuntu 16.04 LTS, try the following:

 sudo apt-get install php-memcached 
+1
source

Just add custom answers. It uses OS / X and homebrew.

First you need to determine which version of PHP you are using locally.

 $ php -v PHP 7.0.19 (cli) (built: May 21 2017 11:56:11) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies $ brew search memcached homebrew/php/php53-memcached homebrew/php/php70-memcached homebrew/php/php54-memcached homebrew/php/php71-memcached homebrew/php/php55-memcached libmemcached ✔ homebrew/php/php56-memcached memcached ✔ 

Since I am running PHP 7.0, I decided to install homebrew / php / php70-memcached

 $ brew install homebrew/php/php70-memcached 

If you do not have homegrown, go to https://brew.sh/ and install it to use these instructions. This was the team the last time I used it.

 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

As soon as I finished all this, I tested by clearing the cache.

 $ php artisan cache:clear Cache cleared successfully. $ 

Hi, this fixed it for me for local development.

+1
source

If you are on Mac OSX, you will need to install Memcached and its PHP dependencies through Homebrew.

 brew update brew doctor brew install memcached 

Then check your version of PHP and install the appropriate PHP interceptors for Memcached.

 php -v 

in my case...

PHP 7.1.4 (cli) (built: April 14, 2017 15:02:16) (NTS)
Copyright (c) 1997-2017 PHP group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

So, I used:

 brew install php71-memcached 

But you can find the required version using

 brew search memcached 

After completing these steps you are likely to get a new error

Memcached servers not added.

So run it with

 brew services restart memcached 

Done!

0
source

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


All Articles