Yiiboilerplate Setup Problem


It seems that the YiiBoilerplate (http://www.yiiframework.com/wiki/374/yiiboilerplate-setup-a-professional-project-structure-in-seconds/) is a really great solution for a Yii project structure and I’m struggling more than five days to setup the YiiBoilerplate on local machine. But from some reason the application can’t connect to the database providing the error: ‘CDbConnection failed to open the DB connection.’.

Here are the configuration details:

  1. Environment on local machine
  • the files are not located in htdocs root, but in subfolder yiiboil

  • db names are yiiboil and yiiboil_test, respectively

  • db user is root

  • db password is blank

  • MySQL works on port 3306

  • I downloaded the latest zip file from the GitHub

  • all files have proper permissions

  1. I made the following changes in files /common/environments/params-prod.php:

return array(

	'env.code' => 'prod',

	// DB connection configurations

	'db.name' => '',

	'db.connectionString' => 'mysql:host=localhost;dbname=yiiboil',

	'db.username' => 'root',

	'db.password' => '',

	// test database {

	'testdb.name' => '',

	'testdb.connectionString' => 'mysql:host=localhost;dbname=yiiboil_test',

	'testdb.username' => 'root',

	'testdb.password' => '',


  1. After the files were saved, I run the command ./runpostdeploy prod migrate in order to configure the application and import data. The following error occured:

‘CDbConnection failed to open the DB connection.’

with the strack trace:

Yii Migration Tool v1.0 (based on Yii v1.1.11)

exception 'CDbException' with message 'CDbConnection failed to open the DB connection.' in /opt/lampp/htdocs/yiiboil/common/lib/Yii/db/CDbConnection.php:388

Stack trace:

#0 /opt/lampp/htdocs/yiiboil/common/lib/Yii/db/CDbConnection.php(331): CDbConnection->open()

#1 /opt/lampp/htdocs/yiiboil/common/lib/Yii/db/CDbConnection.php(309): CDbConnection->setActive(true)

#2 /opt/lampp/htdocs/yiiboil/common/lib/Yii/base/CModule.php(388): CDbConnection->init()

#3 /opt/lampp/htdocs/yiiboil/common/lib/Yii/cli/commands/MigrateCommand.php(442): CModule->getComponent('db')

#4 /opt/lampp/htdocs/yiiboil/common/lib/Yii/cli/commands/MigrateCommand.php(451): MigrateCommand->getDbConnection()

#5 /opt/lampp/htdocs/yiiboil/common/lib/Yii/cli/commands/MigrateCommand.php(482): MigrateCommand->getMigrationHistory(-1)

#6 /opt/lampp/htdocs/yiiboil/common/lib/Yii/cli/commands/MigrateCommand.php(85): MigrateCommand->getNewMigrations()

#7 [internal function]: MigrateCommand->actionUp(Array)

#8 /opt/lampp/htdocs/yiiboil/common/lib/Yii/console/CConsoleCommand.php(173): ReflectionMethod->invokeArgs(Object(MigrateCommand), Array)

#9 /opt/lampp/htdocs/yiiboil/common/lib/Yii/console/CConsoleCommandRunner.php(67): CConsoleCommand->run(Array)

#10 /opt/lampp/htdocs/yiiboil/common/lib/Yii/console/CConsoleApplication.php(92): CConsoleCommandRunner->run(Array)

#11 /opt/lampp/htdocs/yiiboil/common/lib/Yii/base/CApplication.php(162): CConsoleApplication->processRequest()

#12 /opt/lampp/htdocs/yiiboil/common/lib/Yii/yiic.php(34): CApplication->run()

#13 /opt/lampp/htdocs/yiiboil/console/yiic.php(15): require_once('/opt/lampp/htdo...')

#14 /opt/lampp/htdocs/yiiboil/yiic(3): require_once('/opt/lampp/htdo...')

#15 {main}



  1. The problem exists even if I uncomment db params array in /backend/config/main.php and console/config/main.php, e.g.:


'db'=> array(

	'connectionString' => $params['db.connectionString'],

	'username' => $params['db.username'],

	'password' => $params['db.password'],

	'schemaCachingDuration' => YII_DEBUG ? 0 : 86400000, // 1000 days

	'enableParamLogging' => YII_DEBUG,

	'charset' => 'utf8'



  1. I run manually the migration script for creating and importing data in the user table, but the problem still exists.

Consider that all other "pure" Yii projects work without any problems on the local machine even if they are in subfolders.

I have a couple of questions:

  • does anybody know what additional step(s) I should perform or where I made mistakes?

  • can the YiiBoilerplate be configured in a subfolder rather than in a website’s root?

  • should db param in main.php files be uncommented or not?

[color="#006400"]/* Moved from Yii Powered to Extensions … */[/color]

You should setup your database connection info in console/config/main.php file too, because that file is used for deployment and migrations.

i have same problem as you buddy sinix, I dont understand how to setup and run yii boilerplate project ??? if you get some info then please share with me.