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.
4 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 5In addition to the above answer from Tomáš Votruba i had to append the = charachter on OSX. So the full command would be:
composer install -d=/home/someuser/myproject My first post on SO so was unable to simply add this as a comment.
1This works for me, PHP 7.3 on ubuntu 18.04
Install
composer install --working-dir=/your_composer_dir
Update
0composer update --working-dir=/your_composer_dir
Run:
cd /home/mysites/google.com Then run:
composer require facebook/graph-sdk Above steps will open up the directory named (google.com) and install facebook Graph SDK there.
1