When would you place a module in the app/code folder versus another location?

If I add new module in app/code folder with composer.json and another module in vendor folder using composer

What will be the difference ?

  • I am aware about that if module is in vendor folder then It can be updated by composer.
  • Does that same thing apply with the module which is in app/code folder ?
  • When you update module which is in app/code folder using composer they install in vendor directory.

So, What is the point of Composer.json in app/code folder Module ?

  • composer.json specifies the dependencies of your custom module.
    – fmsthird
    Jan 29, 2019 at 8:00
  • files inside vendor folder are installed by the composer on the server. your custom/module will specify the dependencies in composer.json file using require key. That is, to make sure that composer will install packages your custom module has a dependencies.
    – fmsthird
    Jan 29, 2019 at 8:06
  • also, composer json is where your put the metadata for you custom module. You will notice once you check from Magento Module Setup, your custom module will have the information filled in like a vendor name and version and etc taken from the composer.json file. Otherwise, it will display blank or unknown.
    – fmsthird
    Jan 29, 2019 at 8:13

2 Answers 2


As you already pointed out, composer is a package management tool. Any external modules/packages which constitutes your Magento application will be managed by the composer and will be available under vendor directory, provided you have adopted the composer way of installation/ updating of your Magento instance. Magento core modules are also treated as external packages which constitute your Magento application.

app/code expects those Magento modules which are "unique" to your Magento application. Those jobs or customization which we cannot achieve by a third party/external modules has to be here. In most of the time, these modules are not installed or updated using composer. In most of the projects, your version system generally holds and manage your app/code folder only (There are other folder files we need to keep inside a versioning system, but none of them as relevant as modules inside app/code.

But it is a good practice to keep a composer.json file for those modules too. Reasons are many:

  • Magento recommends it as a good practice.
  • You can specify your module dependencies there. ex: php version, core module dependencies etc.
  • If in case, if you want to make your module a general third-party extension, then it would be so easy.

If you need more details of composer.json files which are using in Magento, you can follow this official documentation about the composer.json file.

  • Thanks @Rajeev for the explanation it clears a lot. +1 Jan 29, 2019 at 9:36

Modules in vendor folder would update using composer

And all the modules in app/code would not be updated through composer

That's why when you need to override any module you add it in app/code


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.