Migrate Yii1 project to Yii2

Hello, everyone.

I know that this topic has been discussed here and there with a small pieces of information and sorry if I make a duplicate - I haven’t found suitable topic with my question.

To be short: I have a big Yii1 based app and I want to migrate it to Yii2. Is there any way to have a hybrid app like described in migration guidelines?

Under hybrid app I understand an app, where some components ( Model, View, Controller ) are Yii1 and some are Yii2. As per migration guide and discussion from here: https: //github.com/yiisoft/yii2/issues/10028#issuecomment-187115996 ( remove the space after "https:", sorry limitation of newbies for posting links ). I cannot have any component written in hybrid manner. In fact migration guideline leads me an instance of Yii2 app, which have a very limited application. I still need to continue coding in Yii1 style since request processing is Yii1 driven.

So what is the best practice in migrating app in this case? How big apps are migrating? Complete rewrite is the only option?

Thanks in advance.

Bump

yii2 is totally different than yii1. It like banana and apple comparison. You have to rewrite everything

Thank you for your reply. Yes, I’m aware about differences, however, I thought that there is way to at least have some component from Yii1 working in Yii2 environment. For instance models.

Rewriting whole system is actually a show stopper in migration. Nobody wants to have development of a system to be stalled for months, cause system is being rewritten.

Having some kind of a bridge layer between Yii1 and Yii2, which would fix routing could make such migration much faster.

Think about it this way:

Everybody wants to be given a golden opportunity to refactor, clean and revise the code base. :)

If you don’t want to stall, then perform the rewrite in parallel.

I think that you will find that Yii2 will give you a much cleaner and manageable code base.

At least that’s my experience after porting to it.

Edit:

The difference between my Yii1 code and my Yii2 code is night and day. Honestly!

We’re stuck on 1.1 at Stay.com because of quite large codebase and the state of the project when we’re not changing much at PHP side focusing on mobile apps more. So yeah, it happens :)

You’re right and clean code base is a very strong argument. However in case code base is big and changed frequently ( my case ), parallel development is getting really hard as almost everything will need to be backported. I.e. development will become appox 2 times slower.

Also, when I say "Nobody wants to stall" I mean from business prospective. Developers are completely fine with stalling, refactoring, polishing, refactoring again, etc.

We’re looking now either at developing a bridge between Yii1 and Yii2, so for instance I call Yii2 controller and model, but model in fact will be a proxy to a Yii1 model, until it’s migrated. And other way is not rewrite by module, i.e. module 1 is routed to Yii1 app, module 2 to Yii2 app. This causes issues with models interaction though and will require some number of modules to be migrated in one shot.

samdark`s case is fine: if it’s working, don’t fix it.