5
votes

I loaded up Laravel/Lumen on the new Homestead php7 box and encountered this error:

FatalThrowableError in MemcachedConnector.php line 51:
Fatal error: Class 'Memcached' not found

Doing a phpinfo(); shows there is no memcached extension, but sudo service memcached status says memcached is running. It seems there is a php7 branch for memcached here: https://github.com/php-memcached-dev/php-memcached/tree/php7

Can anyone guide me on how to get it working in the new php7 Homestead VM?

EDIT: I just saw on the homestead install documentation that it says "Memcached (PHP 5.x Only)". Question still remains on how to get it working.

2
It's now working on Forge, which is awesomeprograhammer
Memcached (ending in a 'd') works for me on Laravel 5.4 Homestead on Windows 10 when I do a very basic test. However, certain key/values are failing to save, and I haven't figured out the cause yet.Ryan
Ahh, the reason only my basic test was working and not my more complicated cases was because I misunderstood how tags work. I didn't know that I needed to specify tags during a get as well (and I still don't really understand why).Ryan

2 Answers

5
votes

The work on php-memcached for PHP7 is not yet complete, not all tests pass; You can use everything but JSON serialization, I think.

There is no pecl support for PHP7, so right now you need to install extensions manually, like this:

git clone https://github.com/php-memcached-dev/php-memcached
cd php-memcached
git checkout php7
phpize
./configure
make
sudo make install

You must make sure that phpize is the PHP7 version. Additionally, if the php in your PATH is not PHP7, then the php-config in your PATH is not either, in this case you must pass --with-php-config=/absolute/path/to/php7-config to ./configure.

0
votes

I have the same problem, but on Windows when using XAMPP. It seems memcached works for now with PHP 5+ only.

The problem for Windows users is to find the right .dll file named php_memcache.dll (x86/x64 platforms).

I've spent hours looking for a solution, but nothing found. The very fresh description how to use memcached is here:

HOW TO: Install Memcache on XAMPP (Windows 7/8/10)

We still have to wait for PHP7+ implementation.