How to use custom gitlab repository in symfony

I develop custom symfony bundle and store it in gitlab repository. I want to use this bundle in my symfony project, but faced with an error when I try to install this bundle by composer.

Because it's custom private repo I added custom repository URL in my project composer.json

"repositories": [
    {
        "type" : "vcs",
        "url"  : "git@gitlab.com:custom-team/customn-symfony-bundle.git"
    }
],

but when I try to execute composer require custom-team/customn-symfony-bundle:dev-master I get the following error:

Could not find a matching version of package custom-team/custom-symfony-bundle. Check the package spelling, your version constraint and that the package is available in a stability which matches your minimum-stability (dev).

What is the error? What do I need to change in my symfony bundle repo?

1 answer

  • answered 2021-05-15 19:44 riki-tik

    Sorry, I found a solution by documentation: https://docs.gitlab.com/ee/user/packages/package_registry/index.html

    Created package:

    curl --data branch=MYBRANCH "https://__token__:MYTOKEN@gitlab.com/api/v4/projects/<PACKAGE_ID>/packages/composer"
    

    And added in composer.json

    composer config repositories.gitlab.com/<ID> '{"type": "composer", "url": "https://gitlab.com/api/v4/group/<ID>/-/packages/composer/packages.json"}'