Some articles encourage to create custom extensions in app/code and some other encourage to create them under vendor. Are both these two methods fine?

What if I want to override a module in vendor? Do I need to write my custom module also inside vendor folder or app/code?

Do they act as codepools as in Magento 1.x?

Please anyone clarify the purpose of each directories.

  • According to me we need to make it in app/code.
    – Arjun
    Jul 13, 2016 at 7:37

2 Answers 2


You can look at the folders app/code and vendor as the codepools in M1, but they are not really codepools.
There is no "codepool" concept in M1.

  • vendor folder is for modules you download via composer. You should not write code in that folder.
  • app/code is your playground. Add your own extensions here.

If you need to rewrite/extend something in the vendor folder you can do it in the app/code folder. Just make sure you specify the soft dependency in the module.xml of your module, in the same way you did it in M1 in app/etc/modules/Namespace_Module.xml file.
The only difference is that in m2 they are not actually dependencies. They are sequences.
This way your module will be loaded after the one from the vendor folder

  • Not entirely true. If you install M2 via github app/code is not a playground ;) Jul 13, 2016 at 7:40
  • @Marius : Thanks a lot. It cleared the doubt I had. If you want to override XML file in a vendor module, do we still have to mention the dependencies in module.xml ?
    – Sukeshini
    Jul 13, 2016 at 7:43
  • @RaphaelatDigitalPianism. Yes and no. You get the core modules in app/code in that case, but you can still add your own modules. And the only reason you should install m2 via github is to play around with it and/or contribute to it. So this technically still makes app/code your playground.
    – Marius
    Jul 13, 2016 at 7:51
  • @Sukeshini. Not sure about it, but I think you should.
    – Marius
    Jul 13, 2016 at 7:52
  • @Marius agreed w/ everything you said I would have just said app/code/Vendor is your playground so no risk to break core stuff Jul 13, 2016 at 8:35

app/code is definitely the right place for the modules of your projet.

You must never write code inside vendor(this directory is not ignored into your source control), since it is managed by composer only and is dedicated to third party module or module you want to reuse (and you have published on packagist or your own satis repository).


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.