Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running composer in a different directory than current

I don't know if this question has been asked, because searching finds results mostly about moving the libraries installation directory.

I have a globally installed composer command. Is there a way to run, for example, composer install in a different directory than current, i.e. to specify the directory in which I would like tu run the command?

E.g. being in /home/someuser, I would like to acquire the same result as in running composer install it inside /home/someuser/myproject. Of course, one way would be to simply change the current directory, run composer and go back.

like image 254
Przemek Avatar asked Oct 12 '15 11:10

Przemek


People also ask

How do I change the directory in composer?

Try composer install -h . There you'll find an option --working-dir (or -d ). And that's what you're looking for.

Should I install composer locally or globally?

Alternatively, as mentioned before, keeping the globally installed composer regularly updated. Show activity on this post. I would always suggest install globally, it will be easier for you to manage, and you could easily keep it up to date.


1 Answers

Try composer install -h. There you'll find an option --working-dir (or -d). And that's what you're looking for.

Then run:

composer install --working-dir=/home/someuser/myproject 

You can find more in composer docs.


Depending on your operating system, the = might need to be removed:

composer install --working-dir /home/someuser/myproject 
like image 58
Tomas Votruba Avatar answered Sep 28 '22 02:09

Tomas Votruba