0
I’m trying to learn how to use the new Html5 API, Websocket, and I decided to start testing Ratchet, which is a php library. Anyway, I followed all the steps of this tutorial to create a basic chat http://socketo.me/docs/hello-world and when running on the terminal it does not find the Chat.php. class. The file structure is like this:
bin
chat-server.php
src
MyApp
Chat.php
vendor
autoload.php
(...)
composer.json
composer.lock
My files are 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 on forums some similar issues, but no procedure solved
Installed the dependencies of the package?
composer install
. If not, I recommend reading this here: http://br.phptherightway.com/– gmsantos
yes, I installed, uninstalled and installed again to ensure and nothing
– ludmilamm