Menu

#6 Problem with memcached

1.0
open
nobody
None
2015-11-21
2015-03-20
No

Thanks for Laragon!
Just one thing. I am working with Laravel. I had a single problem with memchached. I configured app/cache.php with memcached:

   'driver' => 'memcached',

   'memcached' => array(
      array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
   ),

but I've obtain the following error:

   Class 'Memcached' not found

The problem is Laragon or configuration Laravel?
Thank you and congratulations!

Discussion

  • Leo Khoa

    Leo Khoa - 2015-03-21

    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)

    Code

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

    Please let me know if it works for you and kindly help other developers overcome the problem.
    Btw, thank you for evaluating Laragon 5 Stars.

     

    Last edit: Leo Khoa 2016-11-10
    • Milad

      Milad - 2015-09-27

      where should i put this code in Lumen project?

       
  • Estudio Duplex

    Estudio Duplex - 2015-03-21

    Yes, it works! In my Laravel 4 project:

    app/config/cache.php
    'memcached' =>
        array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
    ),

    app/start/global.php
    if (!class_exists('Memcached')) {
        include ("memcached.php");
    }

    Thanks Leo!

     
    • Rebecca

      Rebecca - 2015-05-21

      Hi,

      For the solution suggested, what is included in memcached.php ?
      Could you please share the details on what this has ?

       
      • Jason Kirow

        Jason Kirow - 2015-05-25

        Hi Rebecca,

        I believe memcached.php is a client class for windows for memcached that Leo decided to include in DIR:\lamp\bin\php\php-5.6.7\PEAR.

        Thanks for including this Leo! Putting the code snippet above the return in the local laravel environment's cache.php worked wonders for me!

        For those wondering, my entire cache.php:

        app/config/localdev/cache.php

        <?php
        
        //added this so that when you do localdev on a windows box, it doesn't crash when looking for memcached.
        if (!class_exists('Memcached')) {
            include ("memcached.php");
        }
        
        return array(
            'driver'    => 'memcached',
            'prefix'       => 'localdev_',
            'memcached' => array(
                array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
            ),  
        );
        
         
        • Rebecca

          Rebecca - 2015-05-26

          Thanks for the details.

           
  • Yoga Hadi Nugroho

    Hi.. I have added the cache.php with what Leo wrote.. but i have this error.. "No Memcached servers added".. Where have I done wrong? Thank you for the support

     

    Last edit: Yoga Hadi Nugroho 2015-11-19
  • Leo Khoa

    Leo Khoa - 2015-11-21

    Hi Yoga,
    You must run Memcached first. Go to Preferences/Services & Ports, then check Memcached.

     

Log in to post a comment.