Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have to migrate an application from Zend Framework 1.12.0 to version 2. There seem to be no migration guides yet. I have already studied ZF2 coding conventions and I adopted dependency injection (ZendDi) and PHP 5.3 namespaces. My goal is to refactor my ZF1 application into a ZF2 module.

Question: Is it possible to proceed step-by-step with an at least partly working application after every step and avoid huge refactoring steps? If yes, what are the steps?

Here's my idea of such a step-by-step migration, but I don't know if I end up with a working application after every step:

  1. Start by setting up the ZF2 Skeleton Application
  2. Set up a new module (MyApp) and reorganize the contents of my ZF1 application into the MyApp module folder structure. Then set up very basic configuration and bootstrapping and migrate the IndexController by extending it from the ZF2 AbstractActionController. The models (Zend_Db) and views (Zend_View) will be migrated later. The goal here is to have a working IndexController::indexAction which doesn't have many dependencies.
  3. Set up more configuration and bootstrapping (Routing, Translate, Locale, Cache, Db, Acl, ViewHelpers, ...). I'd like to set up the ZF1 versions of these components first and migrate them later one by one.
  4. Migrate the other controllers and set up dependency injection into the controllers either with ZendDi or by using the ServiceManager.
  5. Set up automatic deployment by making the old phing scripts work with the new directory structure.
  6. Migrate the views (including helpers) and forms to ZF2.
  7. Migrate the models (from Zend_Db either to ZF2 ZendDb or to Doctrine).
  8. Migrate other ZF1 components one by one (Translate, Locale, Cache, Acl, ...).
  9. Refactoring rehab and long holiday.

However, I will have a workin application after every step only if certain ZF2 components work together with ZF1 components. I have no idea if it's e.g. possible to use ZF1 views (and view helpers) with ZF2 controllers.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
226 views
Welcome To Ask or Share your Answers For Others

1 Answer

Somewhere it was once written that it will be easy peasy with some intermediate layer but I never saw any links or anything in the library that looked just remotely like it.

Now the only thing and latest information you can find is in the documentation's Overview page. It is this:

Note ZF2 is not backward compatible with ZF1, because of the new features in PHP 5.3+ implemented by the framework, and due to major rewrites of many components.

I never expected it to be backwards compatible but the key statement here I believe is the major rewrites of many components.

I've started a new project with ZF2 a few months ago where I only wanted the library; so no MVC which should be easy, right? So far it's been pretty much a nightmare because nothing is the same anymore. Besides some familiar class names or structures the whole framework has been completely rewritten from the ground up.

Things I loved, used a lot and knew by heart like forms, cache or session are completely different. For my project it has cost me a lot of time with no benefit. One of the key objects for ZF2 I thought was overhaul the documentation which is as of these written way worse than the previous one.

For my other existing ZF1.x projects I don't see how to manage an upgrade except to completely rewrite the application.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...