I'm trying to learn how to use the new Html5 API, WebSocket, and I decided to start by testing Ratchet, which is a php library. Anyway, I followed all the steps of this tutorial to create a basic chat link and when running on the terminal it does not find the class Chat.php. I have changed this place class several times and nothing works. The structure of the files looks like this:
bin
chat-server.php
src
MyApp
Chat.php
vendor
autoload.php
(...)
composer.json
composer.lock
My files look like this:
composer.json
{
"autoload": {
"psr-0": {
"MyApp": "src"
}
},
"require": {
"cboden/ratchet": "0.3.*"
}
}
chat-server.php
<?php
use Ratchet\Server\IoServer;
use MyApp\Chat;
require dirname(__DIR__) . '/vendor/autoload.php';
$server = IoServer::factory(
new Chat(),
8080
);
$server->run();
Chat.php
<?php
namespace MyApp;
use Ratchet\MessageComponentInterface;
use Ratchet\ConnectionInterface;
class Chat implements MessageComponentInterface {
public function onOpen(ConnectionInterface $conn) {
}
public function onMessage(ConnectionInterface $from, $msg) {
}
public function onClose(ConnectionInterface $conn) {
}
public function onError(ConnectionInterface $conn, \Exception $e) {
}
}
ps: I found some similar issues in forums, but no procedure solved