Yii Framework Forum

Migrate from yii1 to yii3


(simonebonini) #1

I have a legacy yii1 web application and I want to migrate to yii2.

Rewriting the all application is not possibile, so I’d like to start using yii2 for the new features and migrate the old features incrementally, step by step.

The best way to achieve this seems using yii1 with yii2 as explained in this article

https://www.yiiframework.com/doc/guide/2.0/en/tutorial-yii-integration#using-both-yii2-yii1

Now yii3 is born and one of his property is “the source coding splitting”. I think that this architecture can make easier porting an application from yii1 to yii3 rather than from yii1 to yii2. For example first I can include the ActiveRecord, than the AssetManager, and so on…

Also why not to use the latest framework release ?

What is your opinion? Anyone has already done something similar? Is there any tutorial or article?

Thanks in advance

Simone


#2

There is no stable release of Yii 3 yet, so there may be significant bugs or changes be made that can break your application. If you want to migrate to Yii 3 I recommend to wait until it is released at least in alpha or beta state.


(Alexander Makarov) #3

I’d recommend Yii 2 + clean separation of layers so application could be migrated to Yii 3 easier.


(Fsb) #4

Would be wonderful to have a technical description of such a separation.


(Alexander Makarov) #5

It is mainly about separating Yii-specific code from generalized PHP-only code via interfaces. For example, you have an application that calculates optimal delivery route. You can do it two ways:

  1. Pass Venue models around and use them directly. This way it may be hard to upgrade.
  2. Make a separate DeliveryRouteCalculartor with its own VenueInfoCollection and VenueInfo (plain PHP class, not model). Require passing VenueInfoCollection via its constructor and rely on methods defined in VenueInfo. Then when using DeliveryRouteCalculartor get data from AR models, convert it to VenueInfoCollection and pass it to DeliveryRouteCalculartor constructor. This way you won’t need to re-write DeliveryRouteCalculartor because of framework upgrade or even framework change.

(PhilipLopez) #6

I made a small project a while back using Yii2, mainly because at work all the projects were built using Yii1 when I joined them, pakistan-flag-history so I kinda knew the framework. It was also a go to because it has out of the box REST support, which was needed in my project. The other reasons you might want to go for Yii are: