我试图从YII2开始(我应该说在ASP.NET MVC之后非常困难)并且遇到了这个错误,但是无法解决错误 - 已经设置了id属性点。
<?php
return [
'id' => 'crmapp',
'basePath' => realpath(__DIR__ . '/../'),
'components' => [
'request' => [
'cookieValidationKey' => 'somekey'
],
'urlManager'=>[
'enablePrettyUrl'=>true,
'showScriptName'=>false
]
],
'db'=> [
require(__DIR__.'/db.php'),
]];
这是完整的错误文字:
Fatal error: Uncaught exception 'yii\base\InvalidConfigException' with message 'The "id" configuration for the Application is required.' in C:\xampp\htdocs\crmapp\vendor\yiisoft\yii2\base\Application.php:220 Stack trace: #0 C:\xampp\htdocs\crmapp\vendor\yiisoft\yii2\base\Application.php(202): yii\base\Application->preInit('C:\\xampp\\htdocs...') #1 C:\xampp\htdocs\crmapp\web\index.php(10): yii\base\Application->__construct('C:\\xampp\\htdocs...') #2 {main} thrown in C:\xampp\htdocs\crmapp\vendor\yiisoft\yii2\base\Application.php on line 220
这是web / index.php
<?php
require(__DIR__.'/../vendor/yiisoft/yii2/Yii.php');
$config = (__DIR__.'/../config/web.php');
(new yii\web\Application($config))->run();
答案 0 :(得分:2)
这是你的问题:
$config = (__DIR__.'/../config/web.php');
$config
包含web.php
的路径,而不是其内容。它应该是:
$config = require(__DIR__ . '/../config/web.php');