Reputation: 532
How can i change the database information of my yii2 advanced template? i cant find the database settings.
http://www.yiiframework.com/doc-2.0/guide-index.html
Upvotes: 4
Views: 17762
Reputation:
In /common/config/main-local.php
you set your database settings:
'components' => [
'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=DATABASE_NAME',
'username' => 'DATABASE_USER',
'password' => 'DATABASE_PASSWORD',
'charset' => 'utf8',
],
The installation guide for advanced template is here: https://github.com/yiisoft/yii2-app-advanced/blob/master/docs/guide/start-installation.md
Upvotes: 16
Reputation: 8400
The advanced template has environments
that each define the target specific configuration. Basically after cloning the template you need to make sure you setup the files under the environments
-folder correctly (it comes with dev
and prod
predefined configurations - for development and production environments).
In the config subfolders you'll find the *-local.php
files that indicate configuration specific to that environment.
For the database you have to look in common/config/main-local.php
.
After you're done with that, just navigate back to the templates' root folder and run ./init
. It will ask you which environment you want and put the files in place. Switching to another environment is just an ./init
call away.
Obviously you're not obligated to keep on using the environments if you don't have use for it, you might as well modify the /common/config/main.php
file and add the connection info there. But given that the advanced template assumes multiple deployment stages for your application it is a very good setup.
Upvotes: 3