How to use Github private repository in Packagist and reuse code in Composer

Asked

Viewed 2,084 times

1

I have some private repositories on github, I would like to reuse the code in my applications that are being made in Symfony, because I will need modules that already exist in more than one project and would make it much easier for me to maintain them if I could manage via.

The point is that I know almost nothing of Poser and even less of packagist.

My doubts are as follows:

  1. It is possible to use my private repository from github in the commiserate?
  2. It is possible to relate the private repository to the packagist?
  3. How to make it work?

I found a tutorial on how to distribute data via Composer is why I’m orienting myself.

1 answer

1


Yes, it is possible to use private repositories. You must declare your repository path in the key packages from Composer.json, that way:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/rodrigorigotti/meu-repositorio-privado"
        }
    ],
    "require": {
        "rodrigorigotti/meu-repositorio-privado": "dev-master"
    }
}

One detail: the package name in the key require must be the name of the package in the composer.json dependency! Otherwise it doesn’t work.

Just make sure your public key is set up on Github, as you would normally.

Another detail: when you deploy that project, it’s normal that you can’t access it from the production (or development) instance because the project is private. In this case, don’t forget to set up a deploy key for your private project.

As for points 2 and 3: no, it is not possible to use private projects in Packagist.

  • It helped a lot, I was able to use the git repository with Composer, thanks to the above, I used svn and csv, but there wasn’t a very hard control, it worked more as backup. I’m taking a git beating, but walking. I’ll see later what Deploy Key is and if there’s a way I don’t have to authorize each device, I tried using ssh2 options with public and private key but I couldn’t make it work. thanks again!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.