Setup: Yii2 - advanced template - shared hosting (one domain) - bootstrap4 update not working

Hi all,

I am not able to get the template running after updating to bootstrap4 - configuration told as in title/question. I am running in status production on my native mac apache2 server/localhost.

After updating composer.json with…

"require": {
    "php": ">=5.4.0",
    "yiisoft/yii2": "~2.0.14",
    "yiisoft/yii2-bootstrap4": "*",   <<<<<
    "yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0"
},

…and adding…

'aliases' => [
    '@bower' => '@vendor/bower-asset',
    '@npm'   => '@vendor/npm-asset',
],

…to my two main.php from backend/frontend, and finally do

composer update

inside terminal (with positive replies after updating), I get the following output provided by the browser:

An internal server error occurred.

Checking my error_log file from apache2 server, it states following error:

[Sun Apr 14 18:19:42.976840 2019] [php7:notice] [pid 4634] [client ::1:60206] An Error occurred while handling another error:\nyii\\base\\InvalidConfigException: A circular dependency is detected for bundle 'frontend\\assets\\AppAsset'. in /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/View.php:295\nStack trace:\n#0 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetBundle.php(125): yii\\web\\View->registerAssetBundle('frontend\\\\assets...')\n#1 /Users/johnny/www/yii-application-new/frontend/views/layouts/main.php(13): yii\\web\\AssetBundle::register(Object(yii\\web\\View))\n#2 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(348): require('/Users/johnny/w...')\n#3 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(257): yii\\base\\View->renderPhpFile('/Users/johnny/w...', Array)\n#4 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(399): yii\\base\\View->renderFile('/Users/johnny/w...', Array, Object(frontend\\controllers\\SiteController))\n#5 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(385): yii\\base\\Controller->renderContent('<div class="sit...')\n#6 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/ErrorAction.php(139): yii\\base\\Controller->render('error', Array)\n#7 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/ErrorAction.php(118): yii\\web\\ErrorAction->renderHtmlResponse()\n#8 [internal function]: yii\\web\\ErrorAction->run()\n#9 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Action.php(94): call_user_func_array(Array, Array)\n#10 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(157): yii\\base\\Action->runWithParams(Array)\n#11 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Module.php(528): yii\\base\\Controller->runAction('error', Array)\n#12 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/ErrorHandler.php(108): yii\\base\\Module->runAction('site/error')\n#13 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\\web\\ErrorHandler->renderException(Object(yii\\base\\InvalidConfigException))\n#14 [internal function]: yii\\base\\ErrorHandler->handleException(Object(yii\\base\\InvalidConfigException))\n#15 {main}\nPrevious exception:\nReflectionException: Class yii\\bootstrap\\BootstrapAsset does not exist in /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php:431\nStack trace:\n#0 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php(431): ReflectionClass->__construct('yii\\\\bootstrap\\\\B...')\n#1 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php(365): yii\\di\\Container->getDependencies('yii\\\\bootstrap\\\\B...')\n#2 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php(156): yii\\di\\Container->build('yii\\\\bootstrap\\\\B...', Array, Array)\n#3 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/BaseYii.php(349): yii\\di\\Container->get('yii\\\\bootstrap\\\\B...', Array, Array)\n#4 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetManager.php(264): yii\\BaseYii::createObject(Array)\n#5 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetManager.php(237): yii\\web\\AssetManager->loadBundle('yii\\\\bootstrap\\\\B...', Array, true)\n#6 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/View.php(286): yii\\web\\AssetManager->getBundle('yii\\\\bootstrap\\\\B...')\n#7 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/View.php(291): yii\\web\\View->registerAssetBundle('yii\\\\bootstrap\\\\B...', NULL)\n#8 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetBundle.php(125): yii\\web\\View->registerAssetBundle('frontend\\\\assets...')\n#9 /Users/johnny/www/yii-application-new/frontend/views/layouts/main.php(13): yii\\web\\AssetBundle::register(Object(yii\\web\\View))\n#10 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(348): require('/Users/johnny/w...')\n#11 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(257): yii\\base\\View->renderPhpFile('/Users/johnny/w...', Array)\n#12 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(399): yii\\base\\View->renderFile('/Users/johnny/w...', Array, Object(frontend\\controllers\\SiteController))\n#13 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(385): yii\\base\\Controller->renderContent('<div class="sit...')\n#14 /Users/johnny/www/yii-application-new/frontend/controllers/SiteController.php(77): yii\\base\\Controller->render('index')\n#15 [internal function]: frontend\\controllers\\SiteController->actionIndex()\n#16 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)\n#17 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(157): yii\\base\\InlineAction->runWithParams(Array)\n#18 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Module.php(528): yii\\base\\Controller->runAction('', Array)\n#19 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/Application.php(103): yii\\base\\Module->runAction('', Array)\n#20 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Application.php(386): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))\n#21 /Users/johnny/www/yii-application-new/index.php(17): yii\\base\\Application->run()\n#22 {main}\n\nNext yii\\base\\InvalidConfigException: Failed to instantiate component or class "yii\\bootstrap\\BootstrapAsset". in /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php:433\nStack trace:\n#0 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php(365): yii\\di\\Container->getDependencies('yii\\\\bootstrap\\\\B...')\n#1 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php(156): yii\\di\\Container->build('yii\\\\bootstrap\\\\B...', Array, Array)\n#2 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/BaseYii.php(349): yii\\di\\Container->get('yii\\\\bootstrap\\\\B...', Array, Array)\n#3 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetManager.php(264): yii\\BaseYii::createObject(Array)\n#4 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetManager.php(237): yii\\web\\AssetManager->loadBundle('yii\\\\bootstrap\\\\B...', Array, true)\n#5 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/View.php(286): yii\\web\\AssetManager->getBundle('yii\\\\bootstrap\\\\B...')\n#6 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/View.php(291): yii\\web\\View->registerAssetBundle('yii\\\\bootstrap\\\\B...', NULL)\n#7 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetBundle.php(125): yii\\web\\View->registerAssetBundle('frontend\\\\assets...')\n#8 /Users/johnny/www/yii-application-new/frontend/views/layouts/main.php(13): yii\\web\\AssetBundle::register(Object(yii\\web\\View))\n#9 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(348): require('/Users/johnny/w...')\n#10 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(257): yii\\base\\View->renderPhpFile('/Users/johnny/w...', Array)\n#11 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(399): yii\\base\\View->renderFile('/Users/johnny/w...', Array, Object(frontend\\controllers\\SiteController))\n#12 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(385): yii\\base\\Controller->renderContent('<div class="sit...')\n#13 /Users/johnny/www/yii-application-new/frontend/controllers/SiteController.php(77): yii\\base\\Controller->render('index')\n#14 [internal function]: frontend\\controllers\\SiteController->actionIndex()\n#15 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)\n#16 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(157): yii\\base\\InlineAction->runWithParams(Array)\n#17 /Users/johnny/www/yii-application-new

[Sun Apr 14 18:19:47.005593 2019] [php7:notice] [pid 4636] [client ::1:60207] An Error occurred while handling another error:\nReflectionException: Class yii\bootstrap\BootstrapAsset does not exist in /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php:431\nStack trace:\n#0 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php(431): ReflectionClass->__construct(‘yii\\bootstrap\\B…’)\n#1 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php(365): yii\di\Container->getDependencies(‘yii\\bootstrap\\B…’)\n#2 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build(‘yii\\bootstrap\\B…’, Array, Array)\n#3 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/BaseYii.php(349): yii\di\Container->get(‘yii\\bootstrap\\B…’, Array, Array)\n#4 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetManager.php(264): yii\BaseYii::createObject(Array)\n#5 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetManager.php(237): yii\web\AssetManager->loadBundle(‘yii\\bootstrap\\B…’, Array, true)\n#6 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/View.php(286): yii\web\AssetManager->getBundle(‘yii\\bootstrap\\B…’)\n#7 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/View.php(291): yii\web\View->registerAssetBundle(‘yii\\bootstrap\\B…’, NULL)\n#8 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetBundle.php(125): yii\web\View->registerAssetBundle(‘backend\\assets\\…’)\n#9 /Users/johnny/www/yii-application-new/backend/views/layouts/main.php(13): yii\web\AssetBundle::register(Object(yii\web\View))\n#10 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(348): require(’/Users/johnny/w…’)\n#11 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(257): yii\base\View->renderPhpFile(’/Users/johnny/w…’, Array)\n#12 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(399): yii\base\View->renderFile(’/Users/johnny/w…’, Array, Object(backend\controllers\SiteController))\n#13 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(385): yii\base\Controller->renderContent(’<div class="sit…’)\n#14 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/ErrorAction.php(139): yii\base\Controller->render(‘error’, Array)\n#15 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/ErrorAction.php(118): yii\web\ErrorAction->renderHtmlResponse()\n#16 [internal function]: yii\web\ErrorAction->run()\n#17 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Action.php(94): call_user_func_array(Array, Array)\n#18 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\Action->runWithParams(Array)\n#19 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction(‘error’, Array)\n#20 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/ErrorHandler.php(108): yii\base\Module->runAction(‘site/error’)\n#21 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(Error))\n#22 [internal function]: yii\base\ErrorHandler->handleException(Object(Error))\n#23 {main}\n\nNext yii\base\InvalidConfigException: Failed to instantiate component or class “yii\bootstrap\BootstrapAsset”. in /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php:433\nStack trace:\n#0 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php(365): yii\di\Container->getDependencies(‘yii\\bootstrap\\B…’)\n#1 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build(‘yii\\bootstrap\\B…’, Array, Array)\n#2 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/BaseYii.php(349): yii\di\Container->get(‘yii\\bootstrap\\B…’, Array, Array)\n#3 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetManager.php(264): yii\BaseYii::createObject(Array)\n#4 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetManager.php(237): yii\web\AssetManager->loadBundle(‘yii\\bootstrap\\B…’, Array, true)\n#5 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/View.php(286): yii\web\AssetManager->getBundle(‘yii\\bootstrap\\B…’)\n#6 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/View.php(291): yii\web\View->registerAssetBundle(‘yii\\bootstrap\\B…’, NULL)\n#7 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/AssetBundle.php(125): yii\web\View->registerAssetBundle(‘backend\\assets\\…’)\n#8 /Users/johnny/www/yii-application-new/backend/views/layouts/main.php(13): yii\web\AssetBundle::register(Object(yii\web\View))\n#9 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(348): require(’/Users/johnny/w…’)\n#10 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(257): yii\base\View->renderPhpFile(’/Users/johnny/w…’, Array)\n#11 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(399): yii\base\View->renderFile(’/Users/johnny/w…’, Array, Object(backend\controllers\SiteController))\n#12 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(385): yii\base\Controller->renderContent(’<div class="sit…’)\n#13 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/ErrorAction.php(139): yii\base\Controller->render(‘error’, Array)\n#14 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/ErrorAction.php(118): yii\web\ErrorAction->renderHtmlResponse()\n#15 [internal function]: yii\web\ErrorAction->run()\n#16 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Action.php(94): call_user_func_array(Array, Array)\n#17 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\Action->runWithParams(Array)\n#18 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction(‘error’, Array)\n#19 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/ErrorHandler.php(108): yii\base\Module->runAction(‘site/error’)\n#20 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(Error))\n#21 [internal function]: yii\base\ErrorHandler->handleException(Object(Error))\n#22 {main}\nPrevious exception:\nError: Class ‘yii\bootstrap\ActiveForm’ not found in /Users/johnny/www/yii-application-new/backend/views/site/login.php:20\nStack trace:\n#0 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(348): require()\n#1 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(257): yii\base\View->renderPhpFile(’/Users/johnny/w…’, Array)\n#2 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/View.php(156): yii\base\View->renderFile(’/Users/johnny/w…’, Array, Object(backend\controllers\SiteController))\n#3 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(384): yii\base\View->render(‘login’, Array, Object(backend\controllers\SiteController))\n#4 /Users/johnny/www/yii-application-new/backend/controllers/SiteController.php(84): yii\base\Controller->render(‘login’, Array)\n#5 [internal function]: backend\controllers\SiteController->actionLogin()\n#6 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)\n#7 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)\n#8 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction(‘login’, Array)\n#9 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction(‘site/login’, Array)\n#10 /Users/johnny/www/yii-application-new/vendor/yiisoft/yii2/base

It seems to me that some parts of b4 are loaded correctly but obviously in some other parts of the magic framework there are still missing links/assets regarding the new b4 …if I interpret it correctly…

Maybe some of you guys could help me with this mess… thank you!

tagging:
@samdark

Have you read your error stack trace at all? It says you are using somewhere Bootstrap 3 classes (namespace yii\bootstrap) instead of Bootstrap 4 (yii\bootstrap4).

Hi Pawel!

Thanks for your reply. This is exactly what I also read out of the error log, but since I am brand new to Yii I am not aware of where to correct it… inside of one specific file only, inside of more files (backend/frontend), and which one of the file(s)… do you have an idea?

Best regards,
John

The problem is currently in your AppAsset.php file I guess, where you depend on \yii\bootstrap\BootstrapAsset instead of \yii\bootstrap4\BootstrapAsset

Go through the changes proposed in this pull request to see more spots to fix. It was for basic-app but it should be quiet similar for you: https://github.com/yiisoft/yii2-app-basic/pull/191/files

In general you should switch all namespaces used from yii\bootstrap to yii\bootstrap4. If I’m not mistaken every old Bootstrap 3 class has its new version in Bootstrap 4 package so it should be enough but of course it’s always better to verify and look for those exceptional differences.

Thank you Pawel!

Since I am new to Yii, could you tell me the folders/files where to find those namespaces if you have got them in mind?

Or could you share a link where to find an overview about all of different namespaces, in which file(s) to adjust them (not just bs3/4)?

I mean if I am doing research on google or here inside the forum, for sure I am finding this and that…but I was not able to find a complete list/overview of such things, where to find what… even more I got confused due to contradicting postings, and also some of the solutions look like not “official” or not highly tested, while others transport a feeling like “that’s the way to do it”…

Ok but you know this for sure… :wink:

Sebastian

Thanks machour! I will do so tonight, and hopefully will get on with it :slight_smile:

The problem is that you might have this in many different places. Easiest way is to use your IDE with replace action on all source files (not vendor) and change

yii\bootstrap\ -> yii\bootstrap4\

and

yii\bootstrap; -> yii\bootstrap4;

Hi Pawel, thanks a lot for your support! I will do so, last question for the time being:

If you say in my source files, do you talk about applying the “replace function” really to ALL folders except the vendor folder?

Best,
John

EDIT: please take into Account my setup Yii2/Advanced/shared hosting (one domain)

Well, yes, it should do the trick and not broke anything. Of course you need to verify afterwards if everything is good.