Yii2:致命错误:未捕获的异常 'yii\base\InvalidConfigException'

我非常喜欢这个社区!现在看来我需要自己提问,因为此时我对 Google 不抱任何希望。


所以,我无法让 PHP 网站工作。它给出了这样的错误:


Fatal error: Uncaught exception 'yii\base\InvalidConfigException' with message 'The "id" configuration for the Application is required.' in /var/www/www-root/data/www/abc/vendor/yiisoft/yii2/base/Application.php:220 Stack trace: #0 /var/www/www-root/data/www/abc/vendor/yiisoft/yii2/base/Application.php(202): yii\base\Application->preInit(Array) #1 /var/www/www-root/data/www/somewebsite.com/index.php(20): yii\base\Application->__construct(Array) #2 {main} thrown in /var/www/www-root/data/www/abc/vendor/yiisoft/yii2/base/Application.php on line 220

我的 index.php 是:


<?php

defined('YII_DEBUG') or define('YII_DEBUG', true);

defined('YII_ENV') or define('YII_ENV', 'prod');


ini_set('session.save_path', 'tmp');

session_start();   


require(__DIR__ . '/../abc/vendor/autoload.php');

require(__DIR__ . '/../abc/vendor/yiisoft/yii2/Yii.php');

require(__DIR__ . '/../abc/common/config/bootstrap.php');

require(__DIR__ . '/../abc/common/config/bootstrap.php');


$config = yii\helpers\ArrayHelper::merge(

    require(__DIR__ . '/../abc/common/config/main.php'),

    require(__DIR__ . '/../abc/common/config/main-local.php'),

    require(__DIR__ . '/../abc/common/config/main.php'),

    require(__DIR__ . '/../abc/common/config/main-local.php')

);


$application = new yii\web\Application($config);

$application->run();


?>

有什么问题?我根据他们的手册安装了 Yii 框架。


饮歌长啸
浏览 143回答 2
2回答

拉丁的传说

你有没有试过,你的配置文件(即 main.php)return [&nbsp; &nbsp; 'id' => 'app-frontend-example',]

一只甜甜圈

您在配置目录中的配置文件 main.php 应该返回......return [&nbsp; &nbsp; 'id' => 'your_app_if',&nbsp; &nbsp; 'name' => Your App Name ',&nbsp; &nbsp; 'basePath' => dirname(__DIR__),&nbsp; &nbsp; 'bootstrap' => ['log'],&nbsp; &nbsp; 'controllerNamespace' => 'your_application\controllers', // the namespace for you application controller&nbsp;&nbsp; &nbsp; 'modules' => [],&nbsp; &nbsp; 'components' => [&nbsp; &nbsp; &nbsp; &nbsp; 'log' => [&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'traceLevel' => YII_DEBUG ? 3 : 0,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'targets' => [&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'class' => 'yii\log\FileTarget',&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'levels' => ['error', 'warning'],&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ],&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ],&nbsp; &nbsp; &nbsp; &nbsp; ],&nbsp; &nbsp; &nbsp; &nbsp; 'errorHandler' => [&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'errorAction' => 'site/error',&nbsp; &nbsp; &nbsp; &nbsp; ],&nbsp; &nbsp; ],&nbsp; &nbsp; 'params' => $params,];
打开App,查看更多内容
随时随地看视频慕课网APP