从 Zend Framework 1 到 2 的逐步迁移 [英] Step by step migration from Zend Framework 1 to 2

查看:18
本文介绍了从 Zend Framework 1 到 2 的逐步迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将应用程序从 Zend Framework 1.12.0 迁移到版本 2.似乎有 尚无迁移指南.我已经研究了 ZF2 编码约定,并采用了依赖注入 (ZendDi) 和 PHP 5.3 命名空间.我的目标是将我的 ZF1 应用程序重构为 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.

问题:是否有可能在每个步骤之后使用至少部分工作的应用程序避免大量重构步骤?如果是,步骤是什么?

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. 首先设置 ZF2 骨架应用程序
  2. 设置新模块(MyApp)并重新组织我的 ZF1 应用程序的内容到 MyApp 模块文件夹结构中.然后通过从 ZF2 AbstractActionController 扩展它来设置非常基本的配置和引导和迁移 IndexController.模型 (Zend_Db) 和视图 (Zend_View) 将在稍后迁移.这里的目标是让 IndexController::indexAction 没有太多依赖项.
  3. 设置更多配置和引导(路由、翻译、区域设置、缓存、Db、Acl、ViewHelpers 等).我想先设置这些组件的 ZF1 版本,然后再逐个迁移.
  4. 使用 ZendDi 或 使用 ServiceManager.
  5. 通过使旧的 phing 脚本与新的目录结构一起工作来设置自动部署.
  6. 将视图(包括助手)和表单迁移到 ZF2.
  7. 迁移模型(从 Zend_Db 到 ZF2 ZendDb 或到 Doctrine).
  8. 一一迁移其他 ZF1 组件(翻译、区域设置、缓存、Acl 等).
  9. 重构康复和长假.
  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.

但是,只有当某些 ZF2 组件与 ZF1 组件一起工作时,我才会在每一步之后都有一个 workin 应用程序.我不知道它是否是例如可以将 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.

在本指南中,我们将介绍以下内容:

In this guide, we will cover the following:

  1. 用于为代码命名空间的工具.
  2. 用于在 Zend Framework 1 应用程序中使用 Zend Framework 2 的工具.
  3. 并行运行 Zend Framework 2 和 Zend Framework 1 的策略.
  4. 使代码更易于迁移的策略,主要侧重于域逻辑和 MVC 层的清晰分离.
  5. 迁移 MVC 层的策略.
  6. 迁移域层的策略.

http://framework.zend.com/manual/2.1/en/migration/overview.html

这篇关于从 Zend Framework 1 到 2 的逐步迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆