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

1

I have some private repositories in 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 very easy to maintain them if I could manage via composer.

The point is that I do not know anything about composer and even less about packagist.

My doubts are as follows:

  • Can I use my private repository from github in the composer / a>?
  • Is it possible to relate the private repository to the packagist ?
  • How to make it work?
  • I found a tutorial on how to distribute data via composer it is because of him that I am guiding.

        
    asked by anonymous 04.02.2015 / 13:16

    1 answer

    1

    Yes, you can use private repositories. You must declare the path of your repository in the packages key of composer.json, like this:

    {
        "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 require key must be the name of the package that is in the composer.json pendence of the dependency! Otherwise it does not work.

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

    Another detail: When you deploy this project, it is normal for you to be unable to access it from the production (or development) instance because the project is private. In this case, do not forget to set up a deploy key for your private project.

    As for points 2 and 3: no, you can not use private projects in Packagist.

        
    04.02.2015 / 15:27