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
命名空间默认没有Memcached
class。
我不确定你想要达到什么目的,但通常你会:
- 安装 Memcached PECL package,
- 在
config/cache.php
、 中配置所有 Memcached 服务器
- 然后是use Laravel's cache API.
所有这些都在 Laravel documentation 中有详细说明。
我在 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
命名空间默认没有Memcached
class。
我不确定你想要达到什么目的,但通常你会:
- 安装 Memcached PECL package,
- 在
config/cache.php
、 中配置所有 Memcached 服务器
- 然后是use Laravel's cache API.
所有这些都在 Laravel documentation 中有详细说明。