The ConfigurationReader:read method fails after adding repository via composer
jmolivas opened this issue · comments
This is the implementation code:
$reader = new ConfigurationReader;
$composerConfiguration = $reader->read('/path/to/composer.json');
Executed composer command:
composer config repositories.drupal composer https://packagist.drupal-composer.org
The composer.json
repositories section after adding repository via composer config
command:
"repositories": {
"drupal": {
"type": "composer",
"url": "https://packagist.drupal-composer.org"
}
}
The error:
Recoverable fatal error: Argument 1 passed to Eloquent\Composer\Configuration\ConfigurationReader::createRepositories() must be of the type array, object given, called in vendor/eloquent/composer-config-reader/src/ConfigurationReader.php on line 146 and defined in vendor/eloquent/composer-config-reader/src/ConfigurationReader.php on line 279
Recoverable fatal error: Argument 1 passed to Eloquent\Composer\Configuration\ConfigurationReader::createRepositories() must be of the type array, object given, called in vendor/eloquent/composer-config-reader/src/ConfigurationReader.php on line 146 and defined in Eloquent\Composer\Configuration\ConfigurationReader->createRepositories() (line 279 of vendor/eloquent/composer-config-reader/src/ConfigurationReader.php).
The offending line:
src/ConfigurationReader.php#L146
Thanks for the report. Looks like the repository creation code needs to be altered to support that map-style repository list definition. It may require some changes to the schema as well, not sure.
Strangely, I cannot actually find a reference to that style of definition in the Composer documentation anywhere. I know I've seen it before though, so I'd say it's still worth supporting.
If you need a workaround, you should be able to change your repositories definition to:
"repositories": [
{
"type": "composer",
"url": "https://packagist.drupal-composer.org"
}
]
And if you feel like having a crack at a PR, that would also be welcome.
@ezzatron Thanks for the reply. You can find information at the official composer site
The config
command allows you to edit composer config settings and repositories in either the local composer.json
file or the global config.json
file.
https://getcomposer.org/doc/03-cli.md#config
Code example at same page:
php composer.phar config repositories.foo vcs https://github.com/foo/ba
I found more examples by following instructions at drupal.org project documentation:
Sure I can change the definition by hand but my idea for testing this project, was to use it to automate the usage of composer on a few commands of the DrupalConsole project and some of those commands run composer to add a new repository and find Drupal extensions (modules, themes, etc).
No worries, I agree that the feature should be supported by composer-config-reader
. I'll try to address it soon.