PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, March 5, 2022

[FIXED] Composer custom GitLab server dependencies

 March 05, 2022     composer-php, gitlab, package, php, repository     No comments   

Issue

We have a company GitLab server behind a VPN. Packages in there are set as being public, but they are de facto "private" since you can't get to repository without authorizing on our VPN.

I made one repository which has dependency to other (on the same server).

Repo 1:

"name": "xxx/repo1",
"repositories": [
    {
        "type": "vcs",
        "url": "http://pvt/repo2"
    }
],
"require": {
    "xxx/repo2": "dev-master"
},

Repo 2:

"name": "xxx/repo2"

The issue I'm getting is when I try to use repo1 in one of my other services.

"name": "other/service",
"repositories": [
    {
        "type": "vcs",
        "url": "http://pvt/repo1"
    }
],
"require": {
    "xxx/repo1": "dev-master"
},
"minimum-stability": "dev",
"prefer-stable": true,

Doing a composer install like this just tells me that repo2 can't be found. I can solve it like this:

"name": "other/service",
"repositories": [
    {
        "type": "vcs",
        "url": "http://pvt/repo1"
    },
    {
        "type": "vcs",
        "url": "http://pvt/repo2"
    }
],
"require": {
    "xxx/repo1": "dev-master"
},

But this is far from ideal. If I have 10 services and all need repo1 to run, introducing a new dependency inside repo1 would require me to change 10 composer.json files.

Why doesn't this function the same way as with other dependencies, so that all required dependencies of the requested package are pulled automatically?

I tried adding this to config:

"config": {
    "gitlab-domains": [
        "pvt"
    ],
    "gitlab-token": {
        "pvt" : "---my-token---"
    }
},

But this did nothing basically.

I also tried replacing pvt with exact server IP, but nothing changed.

Is there a way to make this work?

Note: I do not want to use any external service like Private Packagist or Satis.


Solution

Is there a way to make this work?

The answer is "no" - see the official Composer's explanation: https://getcomposer.org/doc/faqs/why-can%27t-composer-load-repositories-recursively.md



Answered By - kuba
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing