Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

composer config add repository location without the name

Is there any way to use composer CLI command to add a repository location to composer.json but without stating its name?

You can do:

composer config repositories.<name> vcs /path/to/the/repository

But I'm interested in adding repository location without specifying its name.

Since repositories' locations can be added in composer.json without their names:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/igorw/monolog"
        }
    ],
    "require": {
        "monolog/monolog": "dev-bugfix"
    }
}

I'm interested to add such entry:

        {
            "type": "vcs",
            "url": "https://github.com/igorw/monolog"
        }

by using composer CLI but command:

composer config repositories vcs /path/to/the/repository

fails.

Do you know how to do that?

like image 943
Jimmix Avatar asked Oct 21 '25 15:10

Jimmix


1 Answers

It's not possible at this point. If you take a look at the regex that parses your repositories argument (or repo/repos):

// handle repositories
if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {

https://github.com/composer/composer/blob/1.7.2/src/Composer/Command/ConfigCommand.php#L535

You see it's expecting the repositories.name format. My guess would be that while adding them anonymously would be fine if you don't already have repositories defined, it would break if you started trying to name some of them. Also the unset command wouldn't work because you haven't named it, and running the command repeatedly would continue to add them.

My guess is that it's a deliberate move not to support this. You could always open an issue on the repository to request it though.

like image 194
scrowler Avatar answered Oct 23 '25 05:10

scrowler