Book Image

Magento PHP Developer????s Guide, 2nd Edition

By : Allan MacGregor
Book Image

Magento PHP Developer????s Guide, 2nd Edition

By: Allan MacGregor

Overview of this book

Table of Contents (16 chapters)
Magento PHP Developer's Guide Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The configuration


Creating a barebones extension in Magento requires at least two files: config.xml and the module declaration file. Let's go ahead and create each of our files.

The first file is used to declare the module to Magento. Without this file, Magento would not be aware of any extension files.

The file location is app/etc/modules/Mdg_Hello.xml.

<?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 and 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 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.

<?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 by navigating to Magento Backend at System | Configuration | Advanced.