tonydspaniard / yiinitializr-advanced

Yii Framework project structure boilerplate for advanced application requirements
67 stars 30 forks source link

CDbException on Callback::preUpdate #14

Closed rlmckenney closed 10 years ago

rlmckenney commented 10 years ago

The initial install worked fine and several subsequent updates worked fine. But now when I try to run the update, I get:

Script Yiinitializr\Composer\Callback::preUpdate handling the pre-update-cmd event terminated with an exception

[CDbException]
CDbConnection failed to open the DB connection.

I have triple checked that I only have one valid DB connection defined in the config files. My application works fine, but Yiinitializer is failing when I run composer update.

rlmckenney commented 10 years ago

I have done more testing, including a fresh install pulled today. The continuing error that I see seems to occur only if I am using a MySQL database. If I set it back to the original SQLite database, then the error goes away.

tonydspaniard commented 10 years ago

@rlmckenney thats an interesting error... any chance to see some of your code to test it on my local?

sfsultan commented 10 years ago

Hey, I'm having exactly the same issue. I'm using Win7 with XAMPP. The steps I took are:

  1. Downloaded the yiinitializr-advanced and unzipped into a folder in htdocs -> myfolder.
  2. Commented out the connection string in common -> config and added in the mysql info:

                   'connectionString' => 'mysql:host=localhost;dbname=mydb',
       'username' => 'root',
       'password' => '',
       'enableProfiling' => true,
       'enableParamLogging' => true,
       'charset' => 'utf8',
  3. Ran "php composer.phar self-update" which completes successfully.
  4. Ran "php composer.phar install", it asks me to enter an enviornment, I enter "dev". Then it pops out this:

Environment files creation process finished.

Building runtime 'runtime' folders. ... ... Your runtime folder has been created on ...

Runtime 'runtime'' folders creation process finished.

Building runtime 'assets' folders. Your assets folder has been created on ... ... Runtime 'assets'' folders creation process finished. Script Yiinitializr\Composer\Callback::postPackageInstall handling the post-package-install event terminated with an exception

[CDbException] CDbConnection failed to open the DB connection.

install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader]

"..." mean I have skipped the long file paths.

I've also tried using the DB info in all the "dev" configs but no getting rid of this error.

Verbose output: Exception trace: () at C:\xampp\htdocs\myfolder\common\lib\vendor\yiisoft\yii\framework\db\CDbConnection.php:388 CDbConnection->open() at C:\xampp\htdocs\myfolder\common\lib\vendor\yiisoft\yii\framework\db\CDbConnection.php:330 CDbConnection->setActive() at C:\xampp\htdocs\myfolder\common\lib\vendor\yiisoft\yii\framework\db\CDbConnection.php:308 CDbConnection->init() at C:\xampp\htdocs\myfolder\common\lib\vendor\yiisoft\yii\framework\base\CModule.php:387 CModule->getComponent() at C:\xampp\htdocs\myfolder\common\lib\vendor\yiisoft\yii\framework\logging\CDbLogRoute.php:109 CDbLogRoute->getDbConnection() at C:\xampp\htdocs\myfolder\common\lib\vendor\yiisoft\yii\framework\logging\CDbLogRoute.php:71 CDbLogRoute->init() at C:\xampp\htdocs\myfolder\common\lib\vendor\yiisoft\yii\framework\logging\CLogRouter.php:66 CLogRouter->init() at C:\xampp\htdocs\myfolder\common\lib\vendor\yiisoft\yii\framework\base\CModule.php:387 CModule->getComponent() at C:\xampp\htdocs\myfolder\common\lib\vendor\yiisoft\yii\framework\base\CModule.php:523 CModule->preloadComponents() at C:\xampp\htdocs\myfolder\common\lib\vendor\yiisoft\yii\framework\base\CApplication.php:163 CApplication->__construct() at C:\xampp\htdocs\myfolder\common\lib\vendor\yiisoft\yii\framework\YiiBase.php:125 YiiBase::createApplication() at C:\xampp\htdocs\myfolder\common\lib\vendor\yiisoft\yii\framework\YiiBase.php:113 YiiBase::createConsoleApplication() at C:\xampp\htdocs\myfolder\common\lib\Yiinitializr\Composer\Callback.php:191 Yiinitializr\Composer\Callback::getYiiApplication() at C:\xampp\htdocs\myfolder\common\lib\Yiinitializr\Composer\Callback.php:146 Yiinitializr\Composer\Callback::runHook() at C:\xampp\htdocs\myfolder\common\lib\Yiinitializr\Composer\Callback.php:75 Yiinitializr\Composer\Callback::preInstall() at phar://C:/xampp/htdocs/myfolder/composer.phar/src/Composer/EventDispatcher/EventDispat cher.php:165 Composer\EventDispatcher\EventDispatcher->executeEventPhpScript() at phar://C:/xampp/htdocs/myfolder/composer.phar/src/Composer/EventD ispatcher/EventDispatcher.php:138 Composer\EventDispatcher\EventDispatcher->doDispatch() at phar://C:/xampp/htdocs/myfolder/composer.phar/src/Composer/EventDispatcher/E ventDispatcher.php:107 Composer\EventDispatcher\EventDispatcher->dispatchCommandEvent() at phar://C:/xampp/htdocs/myfolder/composer.phar/src/Composer/Install er.php:206 Composer\Installer->run() at phar://C:/xampp/htdocs/myfolder/composer.phar/src/Composer/Command/InstallCommand.php:110 Composer\Command\InstallCommand->execute() at phar://C:/xampp/htdocs/myfolder/composer.phar/vendor/symfony/console/Symfony/Component/C onsole/Command/Command.php:244 Symfony\Component\Console\Command\Command->run() at phar://C:/xampp/htdocs/myfolder/composer.phar/vendor/symfony/console/Symfony/Compo nent/Console/Application.php:897 Symfony\Component\Console\Application->doRunCommand() at phar://C:/xampp/htdocs/myfolder/composer.phar/vendor/symfony/console/Symfony/ Component/Console/Application.php:191 Symfony\Component\Console\Application->doRun() at phar://C:/xampp/htdocs/myfolder/composer.phar/src/Composer/Console/Application.php:1 17 Composer\Console\Application->doRun() at phar://C:/xampp/htdocs/myfolder/composer.phar/vendor/symfony/console/Symfony/Component/Consol e/Application.php:121 Symfony\Component\Console\Application->run() at phar://C:/xampp/htdocs/myfolder/composer.phar/src/Composer/Console/Application.php:83 Composer\Console\Application->run() at phar://C:/xampp/htdocs/myfolder/composer.phar/bin/composer:43 require() at C:\xampp\htdocs\myfolder\composer.phar:15

sfsultan commented 10 years ago

Oops! I was using the same db configuration in all the config files. Turns out, just use it in the common -> config -> env -> dev.

tonydspaniard commented 10 years ago

@sfsultan glad you found the solution.

leandrok commented 10 years ago

@tonydspaniard Hi Antonio, I have a question please. I'm trying to install Yiinitializr (I used Yiiboilerplate until now, good work!). After execute "php composer.phar install" I face exactly the same error described in this issue ("CDbConnection.connectionString cannot be empty"). I don't want put the connection details (database user and password) in the common/config/main.php file (I have that file under source control). I created the common/config/local.php file in order to override the connection string settings, but for some reason is not working. I guess my configuration is wrong. Can you please post a local.php file sample? I want only override the connection string parameters (and add local.php on the .gitignore file). Thank you very much!