简体   繁体   English

如何在 Windows 上使用 composer 正确安装棘轮?

[英]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.当我开始探索 Ratchet 时,我才开始了解 composer,因此我不知道应该在哪里安装它。

1) Where to install composer.phar file? 1)在哪里安装composer.phar文件? Soe says to the root of my project. Soe 对我的项目的根说。 Some says to where the php installed in my machine.有人说我的机器上安装了php。

I installed composer.phar by clicking on the Composer-Setup.exe here: https://getcomposer.org/download/我通过单击此处的 Composer-Setup.exe 安装了 composer.phar: https : //getcomposer.org/download/

And this gets it installed in C:\\ProgramData\\ComposerSetup\\bin\\composer.phar这让它安装在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.现在我的棘轮项目位于: C:\\projects\\rachet\\index.php目前除了index.php没有其他文件是空的。

2) How to install ratchet now into this path? 2)现在如何将棘轮安装到此路径中? path = C:\\projects\\rachet\\index.php路径 = C:\\projects\\rachet\\index.php

3) in which command prompt I should type to install ratchet or composer in windows? 3)我应该在哪个命令提示符下输入在 Windows 中安装棘轮或作曲家? Currently there are two.目前有两个。 one is php.exe command prompt and the other is opened by typing cmd .一个是php.exe命令提示符,另一个是通过键入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 1)点击从官方composer页面下载composer.exe,链接也由ratchet提供

2) upon installation, the composer.phat is installed in your computers /AppData/ComposerSetup 2) 安装时,composer.phat 安装在您的计算机 /AppData/ComposerSetup

2) open cmd, type composer install -d to set your project folder as your current path 2)打开cmd,输入composer install -d 将你的项目文件夹设置为当前路径

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) 3) 然后输入 composer require cboden/ratchet 并等待 4) 现在您将在项目文件夹中看到 vendor 文件夹,不要关闭终端 (cmd)

5) If you didn't do the step in 2) you'll see vendor folder created inside path mentioned in 2) 5) 如果您没有执行 2) 中的步骤,您将看到在 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/ 6)接下来在供应商文件夹之外创建chat.php和socket.php:参考这里的文件内容: http : //blog.samuelattard.com/the-tutorial-for-php-websockets-that-i-wish-曾经存在/

7) open cmd, type php path to your project:namely php c:/...../socket.php this si to get the server script running. 7)打开cmd,输入项目的php路径:即php c:/...../socket.php this si 来运行服务器脚本。

8) in the same folder create a php file wth this content taken from Ratchet: 8) 在同一个文件夹中创建一个 php 文件,内容取自 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如何输入消息,在 chrome 和 firefox 中安装简单的 websoket 客户端扩展来输入消息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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