php 如何在 Windows 上使用 Composer?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29441950/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:24:48  来源:igfitidea点击:

How to use composer on windows?

phpxamppcomposer-php

提问by Priya Rawat

I have installed xampp on my PC. After that I installed composer using window installer. On the website they tell about composer.json which looks something like this in the example

我已经在我的电脑上安装了 xampp。之后我使用窗口安装程序安装了composer。在网站上,他们讲述了 composer.json 在示例中看起来像这样

{
"require": {
    "monolog/monolog": "1.2.*"
}
}

Where do I put it? How do I run it? I have searched a lot but found nothing. Any suggestion would be great.

我把它放在哪里?我如何运行它?我已经搜索了很多,但一无所获。任何建议都会很棒。

I ran command prompt as administrator with following command

我使用以下命令以管理员身份运行命令提示符

C:\windows\system32>composer

It printed out a bunch of commands. I tried typing

它打印出一堆命令。我试着打字

C:\windows\system32>composer install 

I got an error that composer could not find composer.json file

我收到了 Composer 找不到 composer.json 文件的错误

回答by Sverri M. Olsen

Okay, let's say your website is at:

好的,假设您的网站位于:

C:\xampp\htdocs\mywebsite\

You should put the Composer file at:

您应该将 Composer 文件放在:

C:\xampp\htdocs\mywebsite\composer.json

Then, in your terminal, use these two commands:

然后,在您的终端中,使用以下两个命令:

cd C:\xampp\htdocs\mywebsite
composer install

That should be it.

应该是这样。

You can do various other things with Composer. To find out what type composerin your terminal. It will show you a list of commands you can use.

您可以使用 Composer 做其他各种事情。找出composer终端中的类型。它将显示您可以使用的命令列表。

If you want to know more about a command then you can use composer help [COMMAND], like so:

如果您想了解有关命令的更多信息,则可以使用composer help [COMMAND],如下所示:

composer help install