I followed the Using Yii2 with Yii1 carefully and it led to the following error:
PHP message: PHP Fatal error: Call to a member function get() on a non-object in /Volumes/Sites/yii2yii/vendor/yiisoft/yii2/BaseYii.php on line 344
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}() /Volumes/Sites/yii2yii/web/index.php:0
PHP message: PHP 2. yii\base\Application->__construct() /Volumes/Sites/yii2yii/web/index.php:729
PHP message: PHP 3. yii\base\Application->registerErrorHandler() /Volumes/Sites/yii2yii/vendor/yiisoft/yii2/base/Application.php:199
PHP message: PHP 4. yii\base\Application->getErrorHandler() /Volumes/Sites/yii2yii/vendor/yiisoft/yii2/base/Application.php:330
PHP message: PHP 5. yii\di\ServiceLocator->get() /Volumes/Sites/yii2yii/vendor/yiisoft/yii2/base/Application.php:502
PHP message: PHP 6. yii\BaseYii::createObject() /Volumes/Sites/yii2yii/vendor/yiisoft/yii2/di/ServiceLocator.php:132
The problem is that BaseYii::$container is not set when line 344 in YiiBase is executed
return static::$container->get($class, $params, $type);
I tried adding
Yii::$container = new yii\di\Container;
in the bootstrap before instantiating the Yii2 app. That led to various errors because the autoloader was looking for Yii1 class files in the Yii2 framework base.
Next I tried instantiating the Yii1 app first. That had the same problem, autoloader looking for Yii1 classes in the Yii2.
So I have the feeling this page of the guide is out of step with current code. Is there example code online that’s known to be working with current master? Or perhaps not and you can tell from the above what mistake I’ve made.