Which Framework I Would Put Under Magento 2


This is a response to Alan Kent's post asking the world about which framework they should pick to underly Magento 2. Here are the thoughts of a total outsider who has no understanding of the troubles of managing a large project, and no insight into the current state of the Magento development team, allocation of resources, size of job, etc. In the highly unlikely event that you haven't read Alan's post, you should do that and respond to the poll at the end of the post.

Magento is in a good position, in that it's not a Zend Framework 1 "app". Some things are largely independent of the Zend Framework. Some things are small wrappers around Zend Framework 1 things (cache, log), and some things are highly inspired by their Zend Framework 1 counterparts. The latter two will be the trickiest things to refactor. But Magento doesn't need to worry about a lot of things that it might otherwise have to, had it been more tightly coupled to Zend Framework 1 in the first place. This is fortunate.

But it's still a nontrivial amount of work, and Magento has to balance being a both a platform and a product. This often causes problems. Sometimes they are easy to solve, like versioning, and sometimes they are hard to solve, like "should we prioritise making the platform or the product more compelling?"

Clearly, the question of whether to switch frameworks now falls into this category. The core developers are against a wall now, regarding time before general availability. I know a year sounds like a while, but it's not, and they really are gunning for a 2015 release date, and I'm certain that they would choose the release date over modernising the framework. So if the underlying framework is to be changed, it will come at the expense of something.

My first thought was that the decision made now about the underlying framework would be the decision forever, but my views have evolved in the last twenty-four hours, or so. I now believe it's in Magento's best interest not to aggressively pin itself to a framework or version in the short term. I believe that if the product is focused on, the rest will follow.

If it were my decision, I would ship Zend Framework 2 as the official framework underneath Magento 2, and I would try to make the framework layer of Magento depend only on Zend Framework 2. I would advertise it to developers the way Zend Framework 1 is currently advertised in Magento 1. Note that this doesn't mean that developers have to use Zend Framework 2. There is a PSR autoloader, so a developer can choose any framework they like. But "here is an officially supported one that is not going to be steamrolled, and is going to integrate nicely with the core, and is going to underly much of the core framework. If you're not particularly bothered about using one framework, use this one".

Some modules may depend on Zend Framework 1 in a way that is not easy to refactor. The Magento modules which are not framework modules should be client modules on a level footing with third party modules. And they should be subject to the same rules. If a module depends on Zend Framework 1 and that dependency. Specify that dependency in the composer manifest, and make a note that it should be removed in a future version. And make sure third party developers know that this is an option when it comes to updating modules in time for general availability.

This, I think minimises the work load in the short term, allowing the team to get to work on the stuff that's actually going to sell Magento 2, while not forcing anyone to tie themselves to an antiquated framework. I think it's important to make this change before Magento 2 is released, because a chance to do this with so little pain won't come up in the future. I would hope that this is the last ever lightning strike release of Magento, and that the future is more incremental updates. As long as we're making a clean break, I really feel the time to do this is now.

The reason I say Zend Framework 2 and not something else is because of the similarities between the two. There are massive differences between the two, but they are largely developed by the same people, and the core ideas are the same. I would hope that this would make the refactoring easier than it would were Magento 2 being ported to some other framework.