Magento Certified Developer GuideCategory: 1. BasicsDescribe typical Magento module structure
Manish Prakash Staff asked 1 year ago

Every magento module name has two part Namespace and Module Name. So every module name in magento is like
Namespace_Module e.g Excellence_Test
When creating a module, the first entry point of a module is Namespace_Module.xml file located in ‘app/etc/modules’ folder.

The content of this file is like

<config>
    <modules>
        <Excellence_Test>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Core />
             </depends>
        </Excellence_Test>
    </modules>
</config>

This file specifics the module codepool, if the module is enabled/disabled, and if the module depends on another module.

Next depending on the module codepool, we need to additional files/folder

1. app/code/local/Excellence/Test/etc/config.xml : The main configuration of the module, without this module wont work. Defines various things like module version, frontend/admin routes, helpers, blocks, models, and many more things.
2. app/code/local/Excellence/Test/Helper/Data.php: Usually an empty class which extends Mage_Core_Helper_Abstract. This is also an important file, used for things like translation, etc
3. app/code/local/Excellence/Test/Model : This folder contains all model and resource models
4. app/code/local/Excellence/Test/Block: This folder contains all block files
5. app/code/local/Excellence/Test/controllers: This folder contains all frontend and admin controllers
6. app/code/local/Excellence/Test/sql/excellence_test_setup: This folder contains all setup/upgrade scripts
7. app/design/frontend/[package]/[theme]/layout: the layout files related to a module
8. app/design/frontend/[package]/[theme]/template: templates files related to a module

This is a typical module structure in magento