Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

(PHP) Composer and private repositories: how to?

Marcel January 16, 2019

Atlassing can't tell me this (tried support but they can't tell me, because of lack of experience), but they pointed me to this form, which I've search for an hour.

 

BTW: I'm not looking for a Satis solution, because it is another process running on everybodies computer. I'm looking for a direct solution.

We have private repositories that are in use in other private repositories.
So we want composer (php package manager) to get a repository (even when it is private)

But somehow I get errors like:
Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package our_vendor/our_private_package could not be found in any version, there may be a typo in the package name.

Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
- It's a private package and you forgot to add a custom repository to find it

  • I am pretty sure there is no typo, since I can git clone it and that works.
  • I can get the dev branch
  • When I do composer update -vvv, I can see it clones the correct repository
    • also after a composer clearcache

To show that I have/did/tried:

I have a dev-branch on a private repository

"repositories":[
{
"type": "git",
"url": "git@bitbucket.org:our_vendor/our_private_package.git"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"our_vendor/our_private_package": "*@dev"
},

I tried:

  • setting up oauth in a auth.json (in a .composer directory)
    • with a consumer key/sxecret that is under my account 
    • unclear how composer would use this
  • setting up oauth in the config part of composer (with the same result)
  • composer self update
"config": {
"bitbucket-oauth": {
"bitbucket.org": {
"consumer-key": "my_key",
"consumer-secret": "my_secret"
}
}
},

I tried to change the requirements

"require": {
"our_vendor/our_private_package": "dev-dev as 1.0.0"
},

or into

"require": {
"our_vendor/our_private_package": "dev-dev"
},

or into

"require": {
"our_vendor/our_private_package": "*"
},

I tried to add the branch to the repository:

"repositories":[
{
"type": "vcs",
"url": "git@bitbucket.org:allunited/smart.git",
"branch": "dev"
}
],

So I tried a lot of things, but without success.

The only thing that works, is to have the repositories point out to a local (git cloned) version of the private repository (the same way Satis does it), but this should not be the end solution.

 

3 answers

0 votes
Hussam Itani
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 4, 2023

I was able to fix this issue by pushing a version tag to my package repository


https://support.atlassian.com/bitbucket-cloud/docs/repository-tags/#Create-and-push-a-tag-to-Bitbucket

I pushed v0.0.1 because it was a very early stage for me. After running composer update, everything worked out.

You can use composer update -vv to get more insights.

Edit: After pushing v0.0.2, composer actually did update my package AND it showed me the commit-id and commit message.

0 votes
Chad Baker
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 24, 2021

Note that the repository you are requiring should also have its own composer.json, the name set for the package there must match the name of the package you are including (vendor/projectname in my example above).

0 votes
IB
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 3, 2019

I've also tried many settings in composer.json, and it took some time to figure out the correct way to do it.

Side note: I'm using a private Gitlab repo here, not sure if it applies to bitbucket as well.

 

This is what works (at least) for me:

{
"repositories": [
{
"type": "git",
"url": "git@my-gitlab-server:ivo/my-package.git"
}
],
"require": {
"ivo/my-package": "*"
},
"minimum-stability": "dev"
}

Good luck and let me know if it worked for you please!

Michael Couillard September 20, 2019

Thanks for this! They key for me was using dev-master because the package is brand new and not yet versioned. Is just a single master line.

"org/package": "dev-master"

IB
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 22, 2019

Glad you found a solution!

Thanks for the update!

Rhys Stubbs
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 26, 2019

I don't suppose you'd be able to share a full configuration? I am having trouble getting this working and I feel as though I have tried all combinations of config!

 

Some things to note:

- Using composers auth.json

- Targeting the master branch using "dev-master"

- Using the https URL as suggested by composers documentation

 

The error I am currently receiving is "fatal: repository 'git@bitbucket.org/{VENDOR}/{REPO}.git' does not exist" but I have receive various error depending on the composer.json I use.

 

Any help would be awesome!

 

Michael Couillard October 2, 2019

Sure, the new pieces to make it work are just in the parent projects composer.json

"bitbucket-oauth": {
 "bitbucket.org": {
  "consumer-key": "key-name-goes-here",
  "consumer-secret": "ssh-rsa..."
 }
},
"repositories" : [
{
"type": "vcs",
"url": "git@bitbucket.org:DOMAIN/REPO.git"
}
],
"require": {
...
"DOMAIN/REPO": "dev-master"
}

 

Also in the child library projects composer.json I added this because we don't have real usage of branches/tags (yet), so pulling from master is fine

"extra": {
"branch-alias": {
"dev-master": "master"
}
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events