I am trying to run the Ratchet application demo but I can't execute the file
This is my file structure
/var/www/src/MyApp/
/var/www/src/MyApp/chat.php
/var/www/src/MyApp/chat-server.php
<?php use Ratchet\Server\IoServer; use MyApp\Chat; #require "chat.php"; require 'vendor/autoload.php'; $server = IoServer::factory( new Chat(), 8080 ); $server->run();
/var/www/src/MyApp/composer.json
{ "autoload": { "psr-0": { "MyApp": "src" } }, "require": { "cboden/Ratchet": "0.3.*" } }
Vendor Folder is exist in this location
/var/www/src/MyApp/vendor/
Whenever I am executing the chat-server file in terminal I got the following error
PHP Fatal error: Class 'MyApp\Chat' not found in /MyApp/chat-server.php
Please help me how to resolve this
Note: The complete code details are exist in this page
http://socketo.me/docs/hello-world
This question was asked but still no answer for that question too Class 'MyChat\Chat' not found in C:\wamp\www\bin\chat-server.php
If you don't have the composer.json file and the vendor folder at root, it won't work. Also, don't touch the vendor folder (and subfolders). The folder structure must be like this:
/composer.json
/composer.phar
/vendor/[misc]
/src/MyApp/Chat.php
Finally, after updating the composer.json, make sure to run an update:
php composer.phar update
This way it will work.