laravel 来自私人仓库的 composer create-project
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18160115/
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
composer create-project from private repo
提问by Luke Snowden
I have a private project hosted on Bit Bucket. I have an SSH key setup. Is there a way I can use the php composer create-project vendor/name path
command in the same way as If it was on Packagist?
我有一个托管在 Bit Bucket 上的私人项目。我有一个 SSH 密钥设置。有没有办法可以php composer create-project vendor/name path
像在 Packagist 上一样使用该命令?
回答by riotCode
Well there are different ways to accomplish this one being the use of a composer repository that is used instead of packagist.org, which is a better more centralized way to manage your private composer packages. The other method is to use a composer.json that incorporates your private repos within your environments, per environment.
好吧,有多种方法可以实现这一点,即使用 Composer 存储库代替 packagist.org,这是一种更好、更集中的方式来管理您的私有 Composer 包。另一种方法是使用 composer.json 将您的私有存储库合并到您的环境中,每个环境。
First
第一的
Composer allows you to use private repositories to create projects.
Like so...
像这样...
composer create-project vendor/name path --repository-url=http://repo.yourcomposerrepo.com
Since you won't submit a private package to packagist. That url just needs a packages.jsonfile at minimum, you could use satisor your own packagistif you want a more dynamic solution to the packages.json.
由于您不会向 packagist 提交私有包。那个 url至少只需要一个packages.json文件,如果你想要一个更动态的package.json解决方案,你可以使用satis或你自己的packagist。
The method for using composer.json applies to already created projects that will use custom repositories for private packages, not for creating new projects from private repositories. Use the next method if you want to go down a similar route.
使用 composer.json 的方法适用于已创建的项目,这些项目将为私有包使用自定义存储库,不适用于从私有存储库创建新项目。如果您想走类似的路线,请使用下一个方法。
Second
第二
Configure your private repository into your config.jsonglobally for your environment. Then like normally..
针对您的环境将您的私有存储库全局配置到您的config.json 中。然后像平常一样..
composer create-project vendor/name path
回答by Laurence
Yes, Composer allows you to add private projects as 'repositories'to your composer.json file. So therefore you can include private projects into another project.
是的,Composer 允许您将私有项目作为“存储库”添加到您的 composer.json 文件中。因此,您可以将私人项目包含到另一个项目中。
It provides support for GitHub and Bitbucket(as well as SVN and Mercurial).
它提供对 GitHub 和 Bitbucket(以及 SVN 和 Mercurial)的支持。
You need to modify your composer.json file to look something like this:
你需要修改你的 composer.json 文件看起来像这样:
{
"repositories": [ {
"type": "package",
"package": {
"name": "TheShiftExchange/test",
"version": "1.0.0",
"source": {
"url": "https://github.com/TheShiftExchange/test.git",
"type": "git",
"reference": "master"
}
}
}],
"require": {
"laravel/framework": "4.0.*",
"TheShiftExchange/test": "1.0.*"
},
}
回答by iswak
We have Toran Proxy (https://toranproxy.com/) installed as a private packagist, and for that we are able to create projects using command below
我们将 Toran Proxy ( https://toranproxy.com/) 安装为私有包,为此我们可以使用下面的命令创建项目
composer create-project vendor/framework --repository-url=http://your-toran-repo-url/repo/private/ --stability=dev project name
Stability version we use if the project is not tagged or you looking for bleeding edge version.
如果项目未标记或您正在寻找前沿版本,我们将使用稳定版本。
--stability=dev
回答by iruwl
The way I used to:
我以前的方式:
composer create-project vendor/name path --repository="{\"url\": \"https://bitbucket.org/user/project.git\", \"type\": \"vcs\"}" --stability=dev --remove-vcs
Reference: https://getcomposer.org/doc/03-cli.md#create-project
回答by Luke Snowden
Since this post has some traction, I thought I'd add another solution which I use. Open up ~/.bash_profile
由于这篇文章有一些吸引力,我想我会添加另一个我使用的解决方案。打开 ~/.bash_profile
and add something like
并添加类似的东西
function _cmsname {
composer create-project vendor/package --repository-url=http://private.repo.url.co.uk/ --stability=dev ""
}
alias cmsname=_cmsname
and the just type cmsname projectname
in terminal.
和只是输入cmsname projectname
终端。