composer config: add "extra" value as array

Viewed 305

MediaWiki's merge-plugin requires a data structure as follows:

{
    "extra": {
        "merge-plugin": {
            "include": [
                "extensions/OpenIDConnect/composer.json"
            ]
        }
    }
}

How can this data structure (note the array) be created via CLI?

config extra.merge-plugin.include ["extensions/OpenIDConnect/composer.json"] 

will not create the desired output

1 Answers

With Composer 2, this can be accomplished by passing a flag such as --json:

For the example above (note the single quotes parameterizing the JSON object:

composer config --json extra.merge-plugin.include '["extensions/OpenIDConnect/composer.json"]'

Results in:

    "merge-plugin": {
      "include": ["extensions/OpenIDConnect/composer.json"]
    }

Reference: https://github.com/composer/composer/pull/8779

Related