as the title states how can i use memcache in Ratchet websockets.
I isntalled memcache and valided that is is active with php -l
memcache
memcache support => enabled
Version => 4.0.5.2
Revision => $Revision$
I followed a lot of guides (which is a challenge as there is memcache and memcached and Google does mix the two often).
When i follow the official guide and also a lot of stackoverflow posts: nr1, nr2 and number 3 for example.
I think everything is correctly installed, but when i start my server (which starts ratchet and memcache) i get this error:
PHP Fatal error: Uncaught Error: Class “SessionProvider” not found in /var/www/project/websocket/bin/chat-server.php:16
My file looks like:
use RatchetServerIoServer;
use RatchetHttpHttpServer;
use RatchetWebSocketWsServer;
use MyAppChat;
use SymfonyComponentHttpFoundationSessionSession;
use SymfonyComponentHttpFoundationSessionStorageNativeSessionStorage;
use SymfonyComponentHttpFoundationSessionStorageHandlerMemcacheSessionHandler;
use SymfonyComponentHttpFoundationSessionStorageHandler;
require dirname(__DIR__) . '/vendor/autoload.php';
$memcache = new Memcache;
$memcache->connect('localhost', 11211);
$session = new SessionProvider(
new MyApp
, new HandlerMemcacheSessionHandler($memcache)
);
$server = IoServer::factory(
new HttpServer(
new WsServer(
new Chat()
)
),
8080
);
echo("Server Running on 8080n-----------------n");
$server->run();
The structure of my folders is correct as far as i can see.
i’m not sure if and what to add to my composer file, as i cant find anything about it.
{
"autoload": {
"psr-4": {
"MyApp\": "src"
}
},
"require": {
"cboden/ratchet": "^0.4"
}
My goal is simply to share sessions between PHP/webserver and Ratchet to use them.