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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

(PHP) Composer and private repositories: how to?

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.

 

1 answer

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!

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"

Glad you found a solution!

Thanks for the update!

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!

 

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
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,787 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you