Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert yii 1 application to version 2

Tags:

yii

yii2

We have website which built in yii 1.1 version, now we would like to convert it to version 2. But we already have a lots of functionality and we do not have much time to do everything by scratch in yii 2. please do suggest.

like image 380
Asfakhusen Avatar asked Feb 06 '23 05:02

Asfakhusen


1 Answers

I don't think there is a fast way of converting or migrating from Yii 1.1 to Yii2. They are similar in some ways but different enough.

I would recommend you first read most of The Definitive Guide to Yii 2.0, which includes Upgrading from Version 1.1.

In my opinion the best you can do is try to replicate the same modules and their functionality one at a time, trying to reuse as much code as you can from the 1.1 version. A few things that i think would be important are:

  • Create the new Yii2 models using Gii and adapt methods from your Yii 1.1 models. Edit and add validation rules as needed. There are many rules that might not have been available in Yii 1.1, however it can also be true the other way around.

  • Generate Yii2 modules with Gii. Just need these to create a better project structure. If you didn't use modules on Yii 1.1 i would recommend doing so for Yii2.

  • Generate Yii2 CRUDs with Gii inside the corresponding modules. This will help generate the controller, actions, views and search model needed for basic CRUD functionality. After that, you will need to edit the views and controller to fit your needs, which you can use your 1.1 code for reference.

  • Install needed extensions and widgets using composer. Many extensions from Yii 1.1 have updated versions for Yii2, but for those that do not you will have to find substitutes, which shouldn't be too difficult, although you will most likely have to read the documentation for both familiar and new extensions.

In the end you will need to spend time to have a Yii2 version of your website, there is no easy and fast way to jump

like image 144
marche Avatar answered May 02 '23 18:05

marche