問題描述
我必須將應(yīng)用程序從 Zend Framework 1.12.0 遷移到版本 2.似乎有 尚無遷移指南.我已經(jīng)研究了 ZF2 編碼約定,并采用了依賴注入 (ZendDi) 和 PHP 5.3 命名空間.我的目標(biāo)是將我的 ZF1 應(yīng)用程序重構(gòu)為 ZF2 模塊.
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.
問題:是否有可能在每個步驟之后使用至少部分工作的應(yīng)用程序并避免大量重構(gòu)步驟?如果是,步驟是什么?
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?
這是我對這種分步遷移的想法,但我不知道我是否在每一步都得到了一個工作應(yīng)用程序:
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:
- 首先設(shè)置 ZF2 骨架應(yīng)用程序
- 設(shè)置新模塊(MyApp)并重新組織我的 ZF1 應(yīng)用程序的內(nèi)容到 MyApp 模塊文件夾結(jié)構(gòu)中.然后通過從 ZF2 AbstractActionController 擴(kuò)展它來設(shè)置非常基本的配置和引導(dǎo)和遷移 IndexController.模型 (Zend_Db) 和視圖 (Zend_View) 將在稍后遷移.這里的目標(biāo)是讓 IndexController::indexAction 沒有太多依賴項.
- 設(shè)置更多配置和引導(dǎo)(路由、翻譯、區(qū)域設(shè)置、緩存、Db、Acl、ViewHelpers 等).我想先設(shè)置這些組件的 ZF1 版本,然后再逐個遷移.
- 使用 ZendDi 或 使用 ServiceManager.
- 通過使舊的 phing 腳本與新的目錄結(jié)構(gòu)一起工作來設(shè)置自動部署.
- 將視圖(包括助手)和表單遷移到 ZF2.
- 遷移模型(從 Zend_Db 到 ZF2 ZendDb 或到 Doctrine).
- 一一遷移其他 ZF1 組件(翻譯、區(qū)域設(shè)置、緩存、Acl 等).
- 重構(gòu)康復(fù)和長假.
- Start by setting up the ZF2 Skeleton Application
- 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.
- 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.
- Migrate the other controllers and set up dependency injection into the controllers either with ZendDi or by using the ServiceManager.
- Set up automatic deployment by making the old phing scripts work with the new directory structure.
- Migrate the views (including helpers) and forms to ZF2.
- Migrate the models (from Zend_Db either to ZF2 ZendDb or to Doctrine).
- Migrate other ZF1 components one by one (Translate, Locale, Cache, Acl, ...).
- Refactoring rehab and long holiday.
但是,只有當(dāng)某些 ZF2 組件與 ZF1 組件一起工作時,我才會在每一步之后都有一個 workin 應(yīng)用程序.我不知道它是否是例如可以將 ZF1 視圖(和視圖助手)與 ZF2 控制器一起使用.
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.
推薦答案
從 Zend Framework 1 遷移
本指南旨在提供從 Zend Framework 1 遷移到 Zend Framework 2 的工具和策略.沒有適用于每個項目的單一解決方案,也沒有任何工具可以使流程自動化.
This guide is intended to provide tools and strategies for migrating from Zend Framework 1 to Zend Framework 2. There is no single solution that will work for every project, nor any tools to automate the process.
在本指南中,我們將介紹以下內(nèi)容:
In this guide, we will cover the following:
- 用于為代碼命名空間的工具.
- 用于在 Zend Framework 1 應(yīng)用程序中使用 Zend Framework 2 的工具.
- 并行運(yùn)行 Zend Framework 2 和 Zend Framework 1 的策略.
- 使代碼更易于遷移的策略,主要側(cè)重于域邏輯和 MVC 層的清晰分離.
- 遷移 MVC 層的策略.
- 遷移域?qū)拥牟呗?
http://framework.zend.com/manual/2.1/en/migration/overview.html
這篇關(guān)于從 Zend Framework 1 到 2 的逐步遷移的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!