Could someone possibly explain the structure and what files are for in a CRUD module? I have created by module by following a guide online, and its working great and printing out my database fields on the page, but i'm a bit confused as to what some of the files do?

Here are my files so far and what i've gathered they do


I have no idea what the interface file does, some guides have it and some do not and I can't seem to make sense of it.


The block file that connects directly to my template files for rendering data in the templates and layout.


The index file that renders the template for the requested page?


The xml file that specifies the routes for the url.


The module declaration xml file.


I think this file is the one that connects to the database?


I have no idea what the resource model does.


Our actual model file.


The file that installs the database tables.


The index layout file.


The template file that we connect to our block to load data.

I'm fairly new to magento 2, and I haven't used magento 1 before. I think I have a basic understanding of what all the files do, but if someone could briefly explain exactly what each of the files are for, i'd be very grateful!

Thanks in advance

  • Can you share the link that you used to create this CRUD module. Also, have you heard about the repository pattern in magento? Try searching for service contracts in magento. Mar 3, 2020 at 12:51

1 Answer 1


you can check this guide it explain all classes used for CRUD + steps to create and manage custom table in database

source mageplaza

Your Answer

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

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