简体   繁体   中英

How to properly install ratchet using composer on windows?

I've been trying to sort this out for weeks and still couldn't get it right. I just get to know composer once I started to explore Ratchet, thus its confusing as to where should get it installed.

1) Where to install composer.phar file? Soe says to the root of my project. Some says to where the php installed in my machine.

I installed composer.phar by clicking on the Composer-Setup.exe here: https://getcomposer.org/download/

And this gets it installed in C:\\ProgramData\\ComposerSetup\\bin\\composer.phar

Now my ratchet project is located here: C:\\projects\\rachet\\index.php Currently there's no other file other than index.php which is empty.

2) How to install ratchet now into this path? path = C:\\projects\\rachet\\index.php

3) in which command prompt I should type to install ratchet or composer in windows? Currently there are two. one is php.exe command prompt and the other is opened by typing cmd .

For those whom still looking for an answer for the above question, do the following:

1) click to download composer.exe from official composer page, the link also provided by ratchet

2) upon installation, the composer.phat is installed in your computers /AppData/ComposerSetup

2) open cmd, type composer install -d to set your project folder as your current path

3) then type composer require cboden/ratchet and wait 4) you'll see vendor folder inside your project folder now, do not close the terminal (cmd)

5) If you didn't do the step in 2) you'll see vendor folder created inside path mentioned in 2)

6) next create chat.php and socket.php outside of vendor folder: refer here for the files' content : http://blog.samuelattard.com/the-tutorial-for-php-websockets-that-i-wish-had-existed/

7) open cmd, type php path to your project:namely php c:/...../socket.php this si to get the server script running.

8) in the same folder create a php file wth this content taken from Ratchet:

<script>
var conn = new WebSocket('ws://localhost:8080/chat');
conn.onopen = function(e) {
    console.log("Connection established!");
};

conn.onmessage = function(e) {
    console.log(e.data);
};
</script>

open console tab and see new messages displayed here. How to type the message, install simple websoket client extension in chrome and firefox to type the message

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM