Reputation: 3238
I'm trying to start with YII2 (I should say that quite difficult after ASP.NET MVC) and got this error, but can't get what's wrong - id property has been set.
<?php
return [
'id' => 'crmapp',
'basePath' => realpath(__DIR__ . '/../'),
'components' => [
'request' => [
'cookieValidationKey' => 'somekey'
],
'urlManager'=>[
'enablePrettyUrl'=>true,
'showScriptName'=>false
]
],
'db'=> [
require(__DIR__.'/db.php'),
]];
Here is full error text:
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
Here is web/index.php
<?php
require(__DIR__.'/../vendor/yiisoft/yii2/Yii.php');
$config = (__DIR__.'/../config/web.php');
(new yii\web\Application($config))->run();
Upvotes: 2
Views: 5009
Reputation: 2300
Here's your problem:
$config = (__DIR__.'/../config/web.php');
$config
contains the path to web.php
, not its contents. It should be:
$config = require(__DIR__ . '/../config/web.php');
Upvotes: 4