Laravel 5 Error : Class 'App\Utils\Memcached' not found

Laravel 5 Error : Class 'App\Utils\Memcached' not found

我在 centos 7 上安装了 Memcached,根据 phpinfo(),Memcached 3.0.4 可用。我还使用 ps -eaf | 检查了 Memcached | grep Memcached,没问题。 但是,当我尝试在 laravel 中创建 Memcached() 实例时,它 returns 出现错误:

"Class 'App\Utils\Memcached' not found"

这是我的代码:

<?php

namespace App\Utils;

class MemTools {

    private $mem;

    public function __construct() {
        $this->mem = new Memcached();
        $this->mem->addServer('localhost',11211) or die ("Could not connect");
    }
}

App\Utils命名空间默认没有Memcachedclass。

我不确定你想要达到什么目的,但通常你会:

所有这些都在 Laravel documentation 中有详细说明。