I have my private repository on a server. Inside my composer file I have the following JSON:
"repositories": [
{
"type": "composer",
"url": "myrepositoryurl"
}
]
Everything works fine with this. If I run the following command.
composer config repositories vcs myrepositoryurl
I received an error from composer saying:
[InvalidArgumentException]
Setting repositories does not exist or is not supported by this command
If I change the command to
composer config repositories.name vcs myrepositoryurl
Everything works fine and I got the following update inside the composer.json file:
"repositories": {
"name": {
"type": "composer",
"url": "myrepositoryurl"
}
}
Is there any actual difference between these two? And what if I don't want to set a name to my repository url? Can I do that from the command line?
Is there any actual difference between these two?
No. Both JSON elements translate to an array in PHP so they are equivalent, one has numeric keys and the other named keys. So "repositories.key" exists to reference the repo by key from the CLI.
It's not really needed on repositories, because you can add multiple entries with comma separation. Setting the "name" is only relevant on packages (when they are published).
It's only needed, if you want to add multiple repositories (by key name) from the CLI.
This is undocumented, but people run into the issue from time to time. Referencing: https://github.com/composer/composer/issues/2802
And what if I don't want to set a name to my repository url?
Edit the composer.json
file manually.
Can I do that from the command line?
No. From the CLI its either
config key value
orconfig key value1 ... valueN
(array of values)config repositories.key value
.The syntax composer config repositories vcs myrepositoryurl
is not supported, see https://getcomposer.org/doc/03-cli.md#modifying-repositories
Note that the command: composer config repositories.name vcs myrepositoryurl
has the type vcs
and not composer
like in your post.
{
"repositories": {
"name": {
"type": "vcs",
"url": "myrepositoryurl"
}
}
}
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