How can I force composer to install modules in app/code
instead of vendor
directory in Magento 2?
I have few modules they strictly need to be install in app/code
, but when I update them with composer, they install in vendor
directory.
composermagento2module
How can I force composer to install modules in app/code
instead of vendor
directory in Magento 2?
I have few modules they strictly need to be install in app/code
, but when I update them with composer, they install in vendor
directory.
Best Answer
I'm answering my own question, so it will be beneficial for someone else later,
To be able to install in a custom path, your module must support
composer/installers
so add it to your module'srequire
section, eg:and then give your module a custom path in
extra
section, where you want it to be installed. Eg:and your module type must be
"type": "magento-library"
not"type": "magento2-module"
(don't worry changing the type will not break anything, it'll still work like before)so the complete json for the module will be like something this
and just to be sure, add it to your main
composer.json
's extra section too, this maybe optional but I have added it anyway.Then run
composer update
, so it will install your module inapp/code
or your given path.