Creating a bare bones extension in Magento requires at least two files: config.xml
and the module declaration file. Let’s go ahead and create each one of our files.
The first file is used to declare the module to Magento; without this file, Magento will not be aware of any extension files.
The file location is app/etc/modules/Mdg_Hello.xml
. Refer to the following code:
<?xml version=”1.0”?> <config> <modules> <Mdg_Hello> <active>true</active> <codePool>local</codePool> </Mdg_Hello> </modules> </config>
The second XML file is called config.xml
; it is used to specify all the extension configurations, such as routes, blocks, models, and helper class names. For our example, we are only going to be working with the controllers and the routes.
Let’s create the configuration file with the following code.
The file location is app/code/local/Mdg/Hello/etc/config.xml
. Refer to the following code:
<?xml version=”1.0”?> <config> <modules> <Mdg_Hello> <version>0.1.0</version> </Mdg_Hello> </modules> <frontend> <routers> <mdg_hello> <use>standard</use> <args> <module>Mdg_Hello</module> <frontName>hello</frontName> </args> </mdg_hello> </routers> </frontend> </config>
Our extension can now be loaded by Magento, and you can enable or disable our extension in the Magento Backend at System | Configuration | Advanced.