Yii 1 with Yii 2 guide


(nikolas) #1

I know this issue has been discussed quite a few times, but i still don’t seem able to sort out an issue i am facing.

I fillow the instructions on https://www.yiiframework.com/doc/guide/2.0/en/tutorial-yii-integration#using-both-yii2-yii1 however, i probably miss something.
According to the instuctions you fetch yiisoft/yii2 using composer, but there is no mention to initialize / install the project like basic or advanced template, so that you have a complete yii2 structure.

Later on the same text there is a guiedeline

// configuration for Yii 2 application
$yii2Config = require DIR . ‘/…/config/yii2/web.php’;
new yii\web\Application($yii2Config); // Do NOT call run(), yii2 app is only used as service locator

However, since Yii2 hasn’t been initialized, where is config/yii2/web.php supposed to be found?

Any help would be much appreciated


(Alexander Makarov) #2

It is a tutorial for using Yii 2 components within Yii 1.1 application. It seem you need something else.


(nikolas) #3

I was thinking of using Yii 2 components as an intermediate step instead of migrating directly our Yii 1 application to Yii 2, and later on, to perform a full migrate. But although i follow the steps, i keep getting errors, and one of them, is the path of the

$yii2Config = require DIR . ‘/…/config/yii2/web.php’;

config file.


(Alexander Makarov) #4

You specify the config path yourself so you can adjust the place it is stored at…


(nikolas) #5

Thank you for the reply Alexander, ok, this seems somehow more clear now, but what does this config/web.php consist of? for example, in the yii1 installation you already have the basic config in the protected/config directory, but by just fetching yii2 through composer and not bootstraping the installation, you don’t have a yii2 config file in place to start editing.
Perhaps this is the part that i m missing!?


(Alexander Makarov) #6

Something like https://github.com/yiisoft/yii2-app-basic/blob/master/config/web.php

But check how it works in https://www.yiiframework.com/doc/guide/2.0/en/concept-configurations


(nikolas) #7

I think this sounds like the missing part, at least to what i expected :slight_smile: Thank you very much, i ll give it a try this way.


(nikolas) #8

I faced one more minor issue, but it was already covered here Integrate Yii2 Into Yii1 . Was related with CLogger and commenting out

bootstrap => [‘log’]

worked for me as well