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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With