【问题标题】:PHP Ratchet: Class Memcache not foundPHP Ratchet:找不到类 Memcache
【发布时间】:2015-08-29 07:39:24
【问题描述】:

我正在关注 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();

当我在command-line 中运行脚本时,PHP 抛出了一个致命错误:

第 7 行中找不到类 Memcache

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

奇怪的东西

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

【问题讨论】:

  • 您是否有可能在命令行上执行了一个脚本,而另一个通过网络浏览器执行?
  • 您确实必须将 memcache 模块添加到 PHP CLI。但是,抱歉,我不知道如何在 Windows/XAMPP 上执行此操作。
  • 内存缓存问题仍然存在。它是开放的答案。
  • 那么您应该使用有关您的问题的其他信息来更新您的答案。

标签: php ratchet


【解决方案1】:

memcached 服务有两个不同的 PHP 扩展:

  • memcache
  • memcached d

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

您可以找到适合 Windows 的扩展here

【讨论】:

  • Apache 的线程安全扩展,对吧?好吧,我现在不能奖励赏金。稍后会尝试:D
  • 如果你在prefork模式下使用Apache,你可以使用nts版本,意思是不是线程安全的,否则使用ts线程安全) 扩展名。
  • 我现在也有同样的问题,如何安装扩展?
猜你喜欢
  • 2017-05-24
  • 2012-08-06
  • 1970-01-01
  • 2011-06-27
  • 2011-02-09
  • 1970-01-01
  • 2011-11-05
相关资源
最近更新 更多