php 在与当前目录不同的目录中运行 composer
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33080068/
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
Running composer in a different directory than current
提问by Przemek
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?
我有一个全局安装的 composer 命令。例如,有没有办法composer install
在与当前目录不同的目录中运行,即指定我希望在其中运行命令的目录?
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.
例如,在里面/home/someuser
,我想获得与在composer install
里面运行它相同的结果/home/someuser/myproject
。当然,一种方法是简单地更改当前目录,运行 composer 并返回。
回答by Tomá? Votruba
Sure, try composer install -h
. There you'll find an option --working-dir
(or -d
). And that's what you're looking for.
当然,试试composer install -h
。在那里您会找到一个选项--working-dir
(或-d
)。这就是你要找的。
Then run:
然后运行:
composer install -d=/home/someuser/myproject
You can find more in composer docs.
您可以在composer docs 中找到更多信息。
Depending on your operating system, the =
might need to be removed:
根据您的操作系统,=
可能需要删除:
composer install -d /home/someuser/myproject
回答by Eric Mulder
In addition to the above answer from Tomá? Votruba i had to append the = charachter on OSX. So the full command would be:
除了以上 Tomá 的回答?Votruba 我不得不在 OSX 上附加 = 字符。所以完整的命令是:
composer install -d=/home/someuser/myproject
My first post on SO so was unable to simply add this as a comment.
我在 SO 上的第一篇文章因此无法简单地将其添加为评论。
回答by M_R_K
This works for me, PHP 7.3 on ubuntu 18.04
这对我有用,ubuntu 18.04 上的 PHP 7.3
Install
安装
composer install --working-dir=/your_composer_dir
composer install --working-dir=/your_composer_dir
Update
更新
composer update --working-dir=/your_composer_dir
作曲家更新 --working-dir=/your_composer_dir
回答by henlly
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.
以上步骤将打开名为 (google.com) 的目录并在那里安装 facebook Graph SDK。