I have a custom module installed via composer and the path is vendor/company/module/src/registration.php.

I want to override some of these files like vendor/company/module/src/view/template/frontend/main.phtml but no path I tried worked:


I hope there is an easy way to do it and you don't have to create a separate module and extend.

  • You can override by using theme as you mentioned , is there any issue using themes. – Krishna ijjada Sep 22 '16 at 13:21
  • @krishnaijjadaati95Dev yes, it doesn't get parsed, inserted die() or incorrect php syntax. – Claudiu Creanga Sep 22 '16 at 13:24
  • @krishnaijjadaati95Dev deleted var folder and flushed cache – Claudiu Creanga Sep 22 '16 at 13:24
  • @ Claudiu Creanga first test whether the module is working or not, then you can migrate the templates into theme – Krishna ijjada Sep 22 '16 at 13:27
  • @krishnaijjadaati95Dev the module is working properly. if I go to website.com/module-url it is showing up properly. if I edit main.phtml in vendor the change is being picked up, but not if I edit ../theme/.. – Claudiu Creanga Sep 22 '16 at 13:29

Copy templates folder from


Keep your code in


What i have tried Taken the code from


And placed


Working as expected.

  • yes, disregarded view/frontend and it worked. thanks! – Claudiu Creanga Sep 22 '16 at 13:46
  • 1
    and I guess if I want to override Block/Phpfile.php i will have to extend – Claudiu Creanga Sep 22 '16 at 13:50
  • it makes sense though so that composer can update it properly – Claudiu Creanga Sep 22 '16 at 13:51
  • Yes, as well as you know if you want to override only few functions use PLUGIN, or entire class use preference by extending core class. – Krishna ijjada Sep 22 '16 at 13:53

Update for Magento 2.2 & 2.3 You have to place your code in


where Company_Module is the name on etc/module.xml, and no need to put frontend again after module namen and the name of folder is "templates*" and no "template"

Another exemple to override


Override has to be on two different modules and on web folder


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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