Nexcess
Nexcess Blog Logo
June 25, 2015

Book review: Magento Best Practices

Magento Best Practices HandbookFrom time to time, someone publishes a book about Magento that provides worthwhile advice for both for expert and inexperienced developers. Alessandro Ronchi recently published Magento Best Practices Handbook, an eBook providing tips and strategies understandable to anyone that already understands the fundamentals of Magento development.

At 115 pages, the handbook is not long, but it covers essential subjects such as autoload, logging, runtime, Magento MVC, and a simple, powerful strategies for deployment. With short, accessible chapters, the work advises readers to already have a running Magento installation so they can explore its code while studying the handbook’s contents.

Definitions

After exploring few simple definitions like code pools, system configurations, scopes, and factory methods, Ronchi continues to the core concepts.

Magento runtime

In this chapter, Ronchi explains how to run a fully initialized Magento for both the user and administrator, creating a runtime with several approaches.

Logging

This is my favorite chapter of the book. Here, I learned how to use other Magento logging tools in place of the old static Mage::log(). Debugging complete Magento objects can exhaust memory, so Ronchi shows a better approach backed up with code to help us log objects more easily than before.

Autoloading

When Magento was first launched around 2007, useful standards like the PSR-0 Autoloading standard didn’t exist. This chapter explains how the autoload should work and how to extend it to support PSR-0 for third-party library-loading.

Effective MVC

Magento uses a unique approach to MVC with blocks and helpers. This chapter explains how Magento applies the MVC pattern across the framework and highlights the advantages of creating classes based on the software design principle of single responsibility.

Concepts

After discussing definitions, Ronchi proceeds to concepts such as working with data, extensions, and deployment tactics and strategy.

Working with data

Magento is a data-driven platform filled with products, orders, customers, and other entities. In this chapter, Ronchi shows us how to interact with data, collections and how to actually persist the information we manipulate.

Extending Magento

Magento owes much of its success to the flexibility of its framework. It offers several ways to extend the core and Ronchi highlights different scenarios, each of which follow the number one principle in Magento development: “never edit the core files.”

Observers are the favorite approach because, unlike a class rewrite, they are easy and usually conflict-free. Furthermore, Magento 2 makes full use of interceptors, though developers may integrate them into Magento 1 with the Danslo_Aop extension.

Deploying

The market is full of tools to easily deploy projects from a repository to a server. Ronchi lists some options, and then provides an elegant and powerful deploy script written in bash for some simple scenarios. He also offers advice on deployment strategies for more complex ones.

Our giveaway contest

This book offers advice and tools useful to any developer with a grasp of the fundamentals of Magento development, whether a certified professional or an inexperienced journeyman. Ronchi’s handbook contains the advice, recipes, and resources required to develop Magento the right way while presenting maintainable and scalable code that adheres to the best practices of Magento development.

Now, the fun part: we are giving away two free copies and offering ten discounted copies of Ronchi’s eBook, Magento Best Practices. To enter the contest, tweet the link to the article with #magebp and mention @nexcess, after which you will automatically participate.

Avatar for Miguel Balparda
Miguel Balparda
Who is Miguel? If you’re part of the Magento community, chances are you already know. As a Magento Master and open source Community Maintainer, Miguel can be found traveling the world imparting his Magento wisdom at events and approving pull requests everywhere else.