Memcached: Class "Memcached" not found.


  • | 111 points

    Hello,

    I've installed laragon because I saw that it supports Memcached (for windows) but when I run it (memcached was on, I could access the stats page) laravel still gave me the error: Class "Memcached" not found.

    Some help would be nice.


  • administrators
    | 123538 points

    @NexPB: No worries.
    The problem is: Laravel supports only Memcached
    Developing PHP app with Memcached on Windows seems impossible because the PHP extension only support Memcache (note: without a d) on Windows

    However, Laragon solves the problem. Just put the code below to where you feel convenient and it should work (Tested)

    if (!class_exists('Memcached')) {
        include ("memcached.php");
    }
    

    For more details:
    https://sourceforge.net/p/laragon/tickets/6/


  • | 111 points

    @leokhoa Thanks for the answer, altho I've just decided to use redis instead (for my local development env).

    After a lot of googling I found out memcached is not supported very well on windows if at all.


  • administrators
    | 123538 points

    @NexPB : Good decision! Redis is far better than Memcached and is still very fast.


  • | 1309 points

    @NexPB If you really want to use some caching service in Laravel for database, you could also use Database Cache driver. You will have to enable Database cache driver from .env file and add following schema code to your database

    Schema::create('cache', function ($table) {
    $table->string('key')->unique();
    $table->text('value');
    $table->integer('expiration');
    });

    Source; https://www.cloudways.com/blog/integrate-laravel-cache/


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.