PHP Ratchet: Class Memcache not found

蓝咒 提交于 2020-01-02 02:19:50

问题


I am following Ratchet's tutorials. For SessionProvider page, the code is like this:

<?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();

PHP throws a fatal error when I run the script in the command-line:

Class Memcache not found in on line 7

This code is placed in bin\chat-server.php

Wierd Stuff

The class is not available only for chat-server.php script.


回答1:


There are two distinct PHP extensions for the service memcached:

  • memcache
  • memcached <-- note the d

Looks like you have installed the latter one, while you need the first one for your application.

You can find the right extension for Windows here



来源:https://stackoverflow.com/questions/30817560/php-ratchet-class-memcache-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!