HyperGainZ HyperGainZ - 1 year ago 156
PHP Question

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 :


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);


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

Answer Source

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

use Ratchet\Http\HttpServer;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download