PHP棘轮:未找到类Memcache

Rex*_*low 8 php ratchet

我正在关注Ratchet的教程.对于SessionProvider页面,代码如下:

<?php
// Your shell script
use Ratchet\Session\SessionProvider;
use Symfony\Component\HttpFoundation\Session\Storage\Handler;
use Ratchet\App;

$memcache = new Memcache; // Class not found on line 7
$memcache->connect('localhost', 11211);

$session = new SessionProvider(
    new MyApp
  , new Handler\MemcacheSessionHandler($memcache)
);

$server = new App('localhost');
$server->route('/sessDemo', $session);
$server->run();
Run Code Online (Sandbox Code Playgroud)

当我在以下位置运行脚本时,PHP会抛出致命错误command-line:

在第7行找不到类Memcache

此代码放在bin\chat-server.php中

奇怪的东西

该类不仅适用于chat-server.php脚本.

hek*_*mgl 4

该服务有两个不同的memcachedPHP 扩展:

  • memcache
  • memcached<-- 注意d

看起来您已经安装了后一个,而您的应用程序需要第一个。

您可以在此处找到适合 Windows 的扩展

  • 如果您在 prefork 模式下使用 Apache,则可以使用“nts”版本,这意味着“非线程安全”,否则使用“ts”(*线程安全*)扩展。 (2认同)