I am writing a framework which is usable for my future projects. I would like to put the framework to a privately hosted git server, and load it with composer in my future projects.
May I know when I git init, should "--bare" be used? I used to create "bare" repo, but composer said the package is not found. I have searched around, and believe it is due to "missing of composer.json". However, without "--bare", I can't even push my code to server. I "git clone" the framework to another location, and load the location with composer, still failed.
I have tried the two versions below, both failed:
"repositories": [
{
"type": "vcs",
"url": "https://server/git/sdk/"
}
]
"repositories": [
{
"type": "package",
"package": {
"name": "vendor/sdk",
"version": "master",
"source": {
"url": "https://server/git/sdk/",
"type": "git",
"reference": "master"
}
}
}
]
Thanks.
I'm referencing the offical docs on how to load a package from a VCS: https://getcomposer.org/doc/05-repositories.md#using-private-repositories
To require private project B you need two things in the composer.json
file of public project A:
vcs
with the URL to the private repository at your serverrequire it
{
"name": "project A",
"description": "public project A requiring private project B",
"require": {
"vendor/my-private-repo": "dev-master"
},
"repositories": [
{
"type": "vcs",
"url": "[email protected]:vendor/my-private-repo.git"
}
]
}
Then run Composer. It will fetch the private project B into the vendor folder of project A.
May I know when I git init, should "--bare" be used? I used to create "bare" repo, but composer said the package is not found. I have searched around, and believe it is due to "missing of composer.json".
git init --bare
creates a repository without a working tree. That means the repository contains no working or checked out copy of your source files. Only the git revision history of your repo is stored in the root folder of your repository (instead of in a .git subfolder).
I "git clone" the framework to another location, and load the location with composer, still failed.
You don't need to git clone
or git init
the repository to store a local copy, just fetch directly from the private server with Composer.
We have the following situation:
composer.json
should fetch project B from private repo.composer.json
side of to solve this issue (see above)Sidenote: the second repository
definition you posted defines a package
.
This is described in https://getcomposer.org/doc/05-repositories.md#package-2
You are free require the private repo as a package, but its not needed here because the above composer.json
should work just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With