Speed up your Magento store with Managed hosting. Use promo: MGT25 Avail Now

Magento 2 uses Zend Framework 1 (but it’s not that bad)

Magento 2 uses Zend Framework 1 but it is not that bad

“So you are still using Zend Framework 1 on a regular basis?!” he asks with a negative undertone. “You could say that.” you reluctantly answer. Compassionately he responds with “Fortunately I have heard great things about Magento 2 updating its technology stack. I bet you are about to use at least Symfony 3!”. “Y-yeah” is all you can stutter.

The above is a completely fictional dialogue with a developer inquiring about the framework underneath Magento. This post is intended to clear up some common misconceptions and give insight into what the relation is between Magento and the Zend Framework and what the future holds in store for Magento 2 on a framework level.

Picking Zend Framework 1

When Magento 1 was starting development in early 2007, the framework landscape was different than what it looks like today. Magento intended to be a stable, flexible and properly architectured ecommerce software product. The main framworks at that time were Symfony 1, CodeIgniter, CakePHP and the Zend Framework.

Without turning this into a historical framework war, it’s probably safe to say that at the time the Zend Framework was representing the desired values of Magento the most. CakePHP and CodeIgniter were rapid application development frameworks with a so-so architecture. Symfony 1 was new, still in beta and in terms of architecture not that advanced as the Symfony 2 components are today.

The Zend Framework (though just like Symfony still in beta) was backed by the company powering PHP and pretty much the industry standard for Enterprise™ PHP applications. What is important here is that Magento 1.X is not a traditional Zend Framework 1 application but rather implements and relies on components of the framework.

Development of Magento 2

In 2008, the first stable version of Magento got released. Two years later, when Magento was rapidly outpacing its competition, Yoav (former Magento CTO) announced Magento 2. At that point the intention was to completely revamp the underlying architecture to keep up with the modernization of the PHP ecosphere and enable the platform to have further growth over time.

When Zend Framework 2 was hitting a stable version in September 2012, Magento 2 was already underway and being built with Zend Framework 1 components. The official response regarding replacement of Zend Framework 1 with 2 is something along the lines of “return of investment on work required is not that high”.

From someone looking in from the outside, this sounds odd and an observation by Mark painfully summarizes the situation: Zend Framework 3 will be released before Magento 2 which is built with Zend Framework 1 components. Technical debt at its finest.

Though Zend Framework 1 still hasn’t reached the end of life status, Magento is already maintaining its own fork to ensure prolonged compatibility and specific enhancements for Magento 2.

So why is it not that bad?

Magento 1 is not a typical Zend Framework 1 application, yet it is very tightly coupled with it. Instead of treating Zend Framework 1 as a set of components which can be shoved into a project, Magento 1 is very dependent on them.

The “not that bad” part is that Magento 2 is trying to solve this by becoming its own framework. Instead of directly relying on Zend Framework 1, it is leveraging its own adapters and interfaces which are then implemented for tunneling calls to Zend Framework 1 components.

In theory this sounds great and it is not unlikely this is the ideal situation the software designers of Magento 2 have in mind. It would lead to a framework agnostic design and with that in mind the “Which framework would you put under Magento 2?” post by Alan Kent makes much more sense. As a though experiment, that is.

Work in progress

As noted, this is in theory. Practically, Magento 2 is still in more place than one heavily relying on Zend Framework 1. The effort it takes to go from a “tightly coupled” to “framework agnostic” code base is a lot and given the size of the Magento code base, it is immense.

For example, Zend_Json which is included in the Magento 2 composer.json file as Zend Framework 2 component, is actually interfaced to the similarly named Zend Framework 1 component. Doing a quick search painfully reveals that Zend_Json is also more than once directly called in core modules, thus imposing a direct dependency.

A somewhat positive development is that Magento 2 is trying to strip away usage of Zend Framework 1 where possible. They recently (0.74.0-beta1) replaced Zend_Locale and Zend_Date with native PHP implementations.

Final words

Maybe the big takeaway here is that it doesn’t really matter which framework Magento 2 is using under the hood. If you are developing for a platform, you should be using that platform and not be dependent on the framework the platform is trying to abstract away.

Though it would definitely be an improvement to have a more modern framework underneath Magento – Zend Framework 1 is almost 10 years old! – it is not likely Zend Framework 1 usage in Magento will go away anytime soon: the next milestone in the Magento 2 release cycle is the merchant beta and this whole “inner-framework” of Magento 2 is not even completely developed and in use yet.

Of course, all of this is just an opinionated observation. What the future really holds in store, could very well boil down to a cost-over-time graph in some executive department.

Subscribe Newsletter

Subscribe to get latest Magento news

Experience Faster
Managed Magento Hosting