zored/zf2-to-3

从 ZF2 迁移到 ZF3 的技巧。

1.0 2018-01-19 21:38 UTC

This package is not auto-updated.

Last update: 2024-09-29 06:20:10 UTC


README

Build Status Coverage Status

从 ZF2 迁移到 ZF3 的技巧。

为什么?

为了在完全迁移到 ZF3 之前快速修复你的代码。

如何?

  • 在抽象工厂中使用 use \ZF2TO3\ZF2To3AbstractFactoryTrait;
  • 在工厂中使用 use \ZF2TO3\ZF2To3FactoryTrait;
  • 如果控制器依赖于服务定位器,则在控制器自身中使用 use \ZF2TO3\ZF2To3ControllerTrait;
  • 使用 use \ZF2TO3\ZF2To3ServiceLocatorAwareTrait; 和自定义构造函数来 去除 ServiceLocatorAware
  • 更改控制器配置
    <?php
    return [
        'controllers' => [
            // BEFORE:
            'invokables' => [
                'App\Some' => \App\SomeController::class
            ],
            
            // AFTER:
            'factories' => [
                // Controller should be real class:
                \App\SomeController::class => \ZF2TO3\ZF2To3ControllerFactory::class
            ],
        ],
    ];
  • 阅读 迁移文档 并去除这些技巧!