Note that there are some explanatory texts on larger screens.

plurals
  1. POClass 'MyChat\Chat' not found in C:\wamp\www\bin\chat-server.php
    text
    copied!<p>I am trying to implement the basic chat application from <a href="http://socketo.me/docs/hello-world" rel="nofollow">http://socketo.me/docs/hello-world</a>, however I keep getting this error. I tried to move files around, but with no success, but I am quite sure that I don't put the files in the right place. I'm completly new to composer and websockets and psr-0 and I still have a lot to learn about PHP. Here are my path tree and my sources:</p> <pre><code>C:\wamp\www\ bin chat-server.php src MyChat Chat.php vendor {dependencies}+autoload.php composer.json composer.phar composer.lock </code></pre> <p><strong>Chat.php</strong></p> <pre><code>&lt;?php namespace MyChat; require dirname(__DIR__) . '\vendor\autoload.php'; use Ratchet\MessageComponentInterface; use Ratchet\ConnectionInterface; class Chat implements MessageComponentInterface { protected $clients; function __construct() { $this-&gt;clients=new \SplObjectStorage(); } function onOpen(ConnectionInterface $conn) { $this-&gt;clients-&gt;attach($conn); echo "New connection! ({$conn-&gt;resourceId})\n"; } function onClose(ConnectionInterface $conn) { echo "Connection closed: {$conn-&gt;resourceId} \n"; $this-&gt;clients-&gt;detach($conn); } function onError(ConnectionInterface $conn, \Exception $e) { echo "An error has occured: {$e-&gt;getMessage()}. Closing connection... \n"; $conn-&gt;close(); } function onMessage(ConnectionInterface $from, $msg) { $receivers=count($this-&gt;clients)-1; foreach($this-&gt;clients as $client) { if($client!=$from) { $client-&gt;send($msg); } } } } </code></pre> <p><strong>chat-server.php</strong></p> <pre><code>&lt;?php require dirname(__DIR__) . '\vendor\autoload.php'; use Ratchet\Server\IoServer; use MyChat\Chat; $server= IoServer::factory (new Chat() ,8080,'0.0.0.0');//0.0.0.0 is default, means accept all connections $server-&gt;run(); </code></pre> <p><strong>composer.json</strong></p> <pre><code>{ "require": { "cboden/Ratchet": "0.2.*" }, "autoload": { "psr-0": { "MyChat": "src" } } } </code></pre> <p>My php.exe is in C:\wamp\bin\php\php5.4.12 . I would be really thankful for a suggestion, I can't really spot where am I mistaken.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload