Book Image

Magento PHP Developer's Guide

By : Allan MacGregor
Book Image

Magento PHP Developer's Guide

By: Allan MacGregor

Overview of this book

<p>Magento has completely reshaped the face of e-commerce since its launch in 2008. Its revolutionary focus on object oriented and EAV design patterns has allowed it to become the preferred tool for developers and retailers alike.</p> <p>"Magento PHP Developer’s Guide" is a complete reference to Magento, allowing developers to understand its fundamental concepts, and get them developing and testing Magento code.</p> <p>The book starts by building the reader’s knowledge of Magento, providing them with the information, techniques, and tools that they require to start their first Magento development.</p> <p>After building this knowledge, the book will then look at more advanced topics: how to test your code, how to extend the frontend and backend, and deploying and distributing custom modules.</p> <p>"Magento PHP Developer’s Guide" will help you navigate your way around your first Magento developments, helping you to avoid all of the most common headaches new developers face when first getting started.</p>
Table of Contents (16 chapters)
Magento PHP Developer's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The configuration


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.