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
About the Author
About the Reviewers


This book will help new and not-so-new developers understand and work with the Magento fundamental concepts and standard practices in order to develop and test Magento code.

This book is my attempt at writing a book that answers questions that many developers, including myself, had when we started to develop for Magento, for example, what is EAV? How does the ORM in Magento work? What are observers and events? What were the design patterns used to create Magento?

More importantly, it will also answer questions that many developers still have, for example, what is the standard to develop modules and extend the frontend and backend? How can I properly test my code? What is the best method to deploy and distribute custom modules?

What this book covers

Chapter 1, Magento Fundamentals for Developers, discusses Magento's fundamental concepts, such as the system architecture and the MVC implementation and its relation with the Zend Framework. All the concepts in this chapter will set the foundation for developers starting with Magento.

Chapter 2, ORM and Data Collections, introduces you to the Magento ORM system. It explains how collections and models are the bread and butter of everyday Magento development. We will learn how to properly work with data collections and the EAV system.

Chapter 3, Frontend Development, discusses the practical use of the skills and knowledge we have acquired so far, and we'll build a fully functional Magento module step by step. The custom module will allow readers to apply a variety of important concepts, such as working with collections, routing, sessions, and caching.

Chapter 4, Backend Development, extends on what we built in the previous chapter—that is, the frontend part of our module—and create an interface in the Magento backend for interaction with our application data. We will learn about extending the backend and the adminhtml theme, setting data sources, and controlling our extension behavior through configuration.

Chapter 5, The Magento API, discusses the Magento API and how we can extend it to provide access to the custom data that we captured using our extension.

Chapter 6, Testing and Quality Assurance, teaches us the critical skills required to test our custom Magento modules; this is an integral part of development. We will learn about the different types of tests and the tools available for each particular type of test.

Chapter 7, Deployment and Distribution, discusses the multiple tools available in order to deploy our code to a production environment, and we will also learn how to properly pack our extensions for distribution through channels such as Magento Connect.

Appendix A, Hello Magento!, gives new developers a quick and easy-to-follow introduction to create our first Magento extension.

Appendix B, Understanding and Setting Up Our Development Environment, discusses steps to set up a complete environment for Magento development with MySQL and Apache. Additionally, we will go over the tools available to facilitate the development, several IDEs, and version control systems.

What you need for this book

You will need an installation of Magento 1.7, either on a local machine or on a remote server, your favorite code editor, and permissions to install and modify files.

Who this book is for

If you are a PHP developer getting started with Magento or if you already have some experience with Magento and want to understand the Magento architecture and how to extend the frontend and backend of Magento, then this is the book for you.

You are expected to be confident with PHP5. No experience with Magento development is expected, although you should be familiar with basic Magento operations and concepts.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The autoload class takes a single parameter called $class, which is an alias provided by the factory method."

A block of code is set as follows:

Mage::register('original_include_path', get_include_path());
if (defined('COMPILER_INCLUDE_PATH')) {
    set_include_path($appPath . PS . Mage::registry('original_include_path'));
    include_once "Mage_Core_functions.php";
    include_once "Varien_Autoload.php";

Any command-line input or output is written as follows:

$ n98-magerun.php dev:console

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Click on the Submit button."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from:


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.