Class Memcache not found - Session tutorial issue

94 views
Skip to first unread message

Bret Hudson

unread,
Feb 18, 2015, 9:46:50 PM2/18/15
to ratch...@googlegroups.com
I'm having issues with the following PHP code, which is derived from the sessions tutorial on the Ratchet site:

<?php
use Ratchet\App;
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use Ratchet\Session\SessionProvider;
use Symfony\Component\HttpFoundation\Session\Storage\Handler;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcacheSessionHandler;
use TNTWS\UserConnector;

require dirname(__DIR__) . '/vendor/autoload.php';
$memcache = new Memcache;
$memcache->connect('localhost', 11211);
$server = IoServer::factory(
new HttpServer(
new WsServer(
new SessionProvider(
new UserConnector(),
new MemcacheSessionHandler($memcache)
)
)
),
8080
);
$server->run();
?>

I continue to get "Class 'Memcache' not found on line 13". My composer.json is as follows:

{
"autoload": {
"psr-0": {
"TNTWS": ""
}
},
"require": {
"symfony/http-foundation": "2.6.*",
"cboden/ratchet": "0.3.*"
}
}

I've searched for nearly an hour with no luck on finding a solution. Hopefully someone can point out my mistake or find out what's going on. Thanks!

power...@gmail.com

unread,
Mar 30, 2015, 11:22:48 AM3/30/15
to ratch...@googlegroups.com
Hi, you have to install memcache like this "sudo apt-get install php5-memcache"
Reply all
Reply to author
Forward
0 new messages