0
votes

I´m struggling for about 2 days on this... SO and Googling doesnt help me either.

Problem: When I try to access any page on my newly configured Laravel installation, I get the following message:

Class 'Memcached' not found

My enviroment

  • Windows 7
  • Apache 2.4
  • PHP 7.1.8 (TS, x86, Apache module)

if I execute on command line:

λ php -i | grep memcache
memcache
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 32768 => 32768
memcache.compress_threshold => 20000 => 20000
memcache.default_port => 11211 => 11211
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => consistent => consistent
memcache.lock_timeout => 15 => 15
memcache.max_failover_attempts => 20 => 20
memcache.protocol => ascii => ascii
memcache.redundancy => 1 => 1
memcache.session_redundancy => 2 => 2
Registered save handlers => files user memcache

After some googling, I found out that Laravel requires module memcached (yeah... with a final D). So the module that I managed to load, will not work with laravel.

On this SO post (Class 'Memcached' not found-(php 5.4.9,windows 7)), @rockerBOO said that this module wasnt built for windows, and it "should" work if someone compile it...

My resources ended... I didnt found that module DLL, and I have no idea on how to compile it myself.

Anyone knows anything new about this? Or perhaps, could pinpoint me on how to do it myself??

Thx anyway!

2
It could be worth looking into using Laravel Homestead, and running your environment inside a VM laravel.com/docs/5.5/homesteadHarry
another approach could be install Docker and then run memcached as a Container, very easy to setup.Leonardo Cabré
@MacBooc, that article shows how to install the same module that I already have... I´m looking for a module named memcacheD.eduardo.lopes
Do yourself a favor and give Redis a shot. More powerful and more community support as well.ceejayoz

2 Answers

1
votes

To anyone facing this problem, I found a workaround. There´s a package that uses the php_memcache library (yeah, without D).

This library has dll compiled (for php7), and ready to download here:

https://github.com/nono303/PHP7-memcache-dll

And the package for laravel 5 can be downloaded here:

https://packagist.org/packages/swiggles/memcache

Follow instructions to install both, and your´re ready to go!

1
votes

Memcached on Windows doesn't exist, but you can replace it with Memcache on your development environment.

The get function works the same, for the set you need to change the parameters order:

if(!class_exists('Memcached')) {
    class Memcached extends Memcache
    {
        public function set($key, $var, $expire = null)
        {
            /**
             * @see http://php.net/manual/en/memcache.set.php
             * @see http://php.net/manual/en/memcached.set.php
             */
            parent::set($key, $var, null, $expire);
        }
    }
}