lerxx
(lerxx)
January 30, 2019, 11:54am
1
Hello, I have modified my db config file “db.php” like this:
<?php
return [
'components' => [
// ...
'cache' => [
'class' => 'yii\caching\FileCache',
],
'db' => [
'class' => 'yii\db\Connection',
'driverName' => '{Ingres II}',
'dsn' => 'odbc:xxx',
'username' => xx,
'password' => xxx,
'charset' => 'utf8',
'enableSchemaCache' => true,
// Duration of schema cache.
'schemaCacheDuration' => 3600,
// Name of the cache component used to store schema information
'schemaCache' => 'cache',
],
],
];
but get now the error:
Invalid Configuration – yii\base\InvalidConfigException
The configuration for the “db” component must contain a “class” element.
How can I fix this?
machour
(Mehdi Achour)
January 30, 2019, 12:01pm
2
Well, obviously there is a “class” element in your “db” component.
Are you sure that you’re modifying the good file? Is is the one actually read?
It may also happen that you inserted an invisible space character, maybe remove that section and type it again.
lerxx
(lerxx)
January 30, 2019, 12:43pm
3
Hi, I had before editing my db.php some problems with long charging time by displaying an simple page.
So I have searched some solutions and found https://www.yiiframework.com/doc/guide/2.0/en/tutorial-performance-tuning
So I have edited my db.php file and added the parts for “components” and “cache”. But I don’t think, that it will be a solution.
machour
(Mehdi Achour)
January 30, 2019, 12:51pm
4
oh, yeah, totally missed your filename
I assume you’re using one of Yii’s templates. In this case, the db.php
file should just contain the following:
return [
'class' => 'yii\db\Connection',
'driverName' => '{Ingres II}',
'dsn' => 'odbc:xxx',
'username' => xx,
'password' => xxx,
'charset' => 'utf8',
'enableSchemaCache' => true,
// Duration of schema cache.
'schemaCacheDuration' => 3600,
// Name of the cache component used to store schema information
'schemaCache' => 'cache',
],
just the db part, and it’s get included in the main component
array. https://github.com/yiisoft/yii2-app-basic/blob/master/config/web.php#L45
You should set the cache
inside main.php instead, under the components
entry.
Open a new post for your performances issues, you shouldn’t be needing caching on your local environment. It’s more a cherry on the top of your cake for production.
lerxx
(lerxx)
January 30, 2019, 12:59pm
5
Thanks for your reply. Do you mean the main.php under views/layouts?
I will open a new topic about the performance issues in a few minutes.
machour
(Mehdi Achour)
January 30, 2019, 1:01pm
6
No, views/layouts/main.php
is your main layout file (HTML template)
I meant the main file under config/
, which is sometimes main.php
, sometimes web.php
, depending on the Yii template you are using.