Priya Rawat
Priya Rawat

Reputation: 259

How to use composer on windows?

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

{
"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

Upvotes: 19

Views: 64407

Answers (1)

Sverri M. Olsen
Sverri M. Olsen

Reputation: 13283

Okay, let's say your website is at:

C:\xampp\htdocs\mywebsite\

You should put the Composer file at:

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 composer in your terminal. It will show you a list of commands you can use.

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

composer help install

Upvotes: 49

Related Questions