I'm trying out the Ratchet library to use WebSockets located at http://socketo.me/ but am experiencing some problems when running the server script from the command line in Ubuntu.
After successfully installing composer and Ratchet I'm following the tutorial for a basic chat application at http://socketo.me/docs/hello-world and I'm at the Running It step. My file structure, with websockets being my project folder, is:
kingsconflict
websockets
chat.php
chat-server.php
composer.json
vendor
autoload.php
(dependecies included by composer for Ratchet)
The error I get when typing "sudo php chat-server.php" is "PHP Fatal error: require(): Failed opening required '/var/www/kingsconflict/vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/kingsconflict/websockets/chat-server.php on line 5". It seems like it's trying to open /var/www/kingsconflict/vendor/autoload.php but the actual path is /var/www/kingsconflict/websockets/vendor/autoload.php, and I'm not sure why it's doing this.
chat-server.php
<?php
use Ratchet\Server\IoServer;
use MyApp\Chat;
require dirname(__DIR__) . '/vendor/autoload.php'; // Error here
$server = IoServer::factory(
new Chat()
, 8080
);
$server->run();
I tried subbing the errored line with the line below, and I stop getting the error but I get a new error "PHP Fatal error: Class 'MyApp\Chat' not found" which leads me to believe this fix isn't right.
require ('./vendor/autoload.php');
The code for the other files are the same as shown in the Ratchet tutorial, but just in case I'll post them below
chat.php
<?php
namespace MyApp;
use Ratchet\Mess