I'm developing module to call REST API and I want to use an external package via composer. In which composer.json I should put dependency? In composer.json in root directory or composer.json in module directory?
If your module has a
composer.json, this probably means that you installed it via composer. In that case:
- you might want to reuse that module elsewhere
- you have to add the dependency to the module composer.json
- then run
composer update your/module --with-dependenciesin the project root
BUT if the module sits in
app/code and has a
composer.json just to satisfy Magentos package inspection, you will have to add any additional dependencies to the project's
composer.json. You might want to add it to the module's file as well for documentation purpose, but if the module has not been installed via composer, it won't have any effect.