Search code examples
phpwebsocketcomposer-phpratchet

ratchet HttpServer class not found


So i made a real-time chat on windows in php with websockets and every thing worked perfectly but now when i try to run the server on my vps(debian) i get this error

PHP Fatal error:  Class 'Ratchet\http\HttpServer' not found in /react-chat/bin/server.php on line 11

so when i look at my server.php file :

<?php

require __DIR__ . '/../vendor/autoload.php';

use Chat\Chat;

use Ratchet\Server\IoServer;
use Ratchet\http\HttpServer;
use Ratchet\WebSocket\WsServer;

$server = IoServer::factory(new HttpServer(new WsServer(new Chat)), 2000);

$server->run();

every thing seems normal this is my composer.json file

{
    "require": {
        "cboden/ratchet": "~0.3"
    },
    "autoload": {
        "psr-4": {
            "Chat\\": "bin/src/"
        }
    }
}

the only warning i got when doing composer install was following Composer install

but i dont that warning is making the error


Solution

  • PHP namespaces are case sensitive, so try Http instead of http:

    use Ratchet\Http\HttpServer;