Reputation: 6506
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?
Upvotes: 4
Views: 2175
Reputation: 8210
I can't find a way to do that. I would just add it manually (without the cli tool). I did try using composer config repositories._ vcs /url
. It worked, but it obviously set the name to be "_". Then you can go in and delete that. But if you are doing that anyway, you might as well just add it manually anyway.
Upvotes: 0
Reputation: 24405
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.
Upvotes: 2