ratchetphp / Ratchet

Asynchronous WebSocket server
http://socketo.me
MIT License
6.28k stars 743 forks source link

Hello World! tutorial can't find class MyApp/Chat #243

Closed Lugia101101 closed 10 years ago

Lugia101101 commented 10 years ago

Heyo, I have followed every step of the Hello World! tutorial, but can't get past Instantiation. I run it through the command prompt and the following error appears:

php bin\chat-server.php Fatal error: Class 'MyApp\Chat' not found in C:\path\to\install\beta\bin\chat-server.php on line 8

File tree and composer.json can be found here: http://pastebin.com/xEDwVBg0 Just wondering if I missed something or interpreted something wrong. Thank you~

cboden commented 10 years ago

Are you including vendor/autoload.php in chat-server.php?

Lugia101101 commented 10 years ago

This? require dirname(DIR) . '/vendor/autoload.php'; If so, yes.

cboden commented 10 years ago

Can you post the code to your chat-server.php and Chat.php?

scholtz commented 10 years ago

I got the same error..

according to this: http://stackoverflow.com/questions/16868942/ratchet-basic-chat-application-giving-error-failed-opening-required

"php composer.phar update" helped

btw someone should write exactly filestructure to the hello world app, it is not explicitly given where should be chat-server located.. it should be easy to write down:

appfolder/composer.json appfolder/bin/chat-server.php appfolder/src/MyApp/Chat.php

btw, i am referring to tutorial from here: http://socketo.me/docs/hello-world

Lugia101101 commented 10 years ago

Thank you scholtz, the update command fixed it. I might suggest you add a little note about using the update command after editing composer.json as well.

cboden commented 10 years ago

I'm out of town for four days. When I get back I'll update the website documentation with the recently revised way (composer require cboden/ratchet) to install a package as well as a tree structure.

zqhong commented 9 years ago

Thanks a lot. I have the same problem. When I execute php composer.phar update, I fixed it.

My folder tree: ➜ ws tree -L 3 . ├── bin │   └── chat-server.php ├── composer.json ├── composer.lock ├── composer.phar ├── MyApp.php ├── src │   └── MyApp │   └── Chat.php └── vendor ├── autoload.php ├── cboden │   └── ratchet ├── composer │   ├── autoload_classmap.php │   ├── autoload_namespaces.php │   ├── autoload_psr4.php │   ├── autoload_real.php │   ├── ClassLoader.php │   └── installed.json ├── evenement │   └── evenement ├── guzzle │   ├── common │   ├── http │   ├── parser │   └── stream ├── react │   ├── event-loop │   ├── socket │   └── stream └── symfony ├── event-dispatcher ├── http-foundation └── routing

22 directories, 13 files