tonydspaniard / yiinitializr-advanced

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

Install issue #3

Open algebris opened 11 years ago

algebris commented 11 years ago

Can't install, catching db connection exception. [CDbException]
CDbConnection failed to open the DB connection. i've just changed all config files like common/config/env.php, dev.php, prod.php in order to connect to database successfully but without result. What i'm doing wrong? Can't install it quickly

tonydspaniard commented 11 years ago

@algebris After you setup your connection in common/config/environments/dev.php and run:

php composer.phar self-update
php composer.phar install

And making sure that you type the dev environment on request. Still having issues?

minkbear commented 11 years ago

I have the same problem. Step to re produce

  1. download yiinitializr-advanced and install
  2. run php composer.phar self-update php composer.phar install
  3. set dev environment for command asking
  4. config db section in common/config/env/dev.php

when echo db variable in backend app, it shows 'connectionString' => 'sqlite:C:\wamp\www\test_web\common\config/../data/testdrive.db'

I actually insert mysql connectionstring in common/config/env/dev.php It's seem that common/config/env folder is ignored from merging configuration process.

please give me some advice. Thanks

tonydspaniard commented 11 years ago

When you share common config make sure you REMOVE that setting from the backend / frontend / console (check your env.php on those places and also remove it from the environment config files)

Cheers

Enviado desde mi BlackBerry® de Vodafone

-----Original Message----- From: minkbear notifications@github.com Date: Wed, 15 May 2013 01:32:21 To: tonydspaniard/yiinitializr-advancedyiinitializr-advanced@noreply.github.com Reply-To: tonydspaniard/yiinitializr-advanced reply@reply.github.com Cc: Antonio Ramirezantonio@ramirezcobos.com Subject: Re: [yiinitializr-advanced] Install issue (#3)

I have the same problem. Step to re produce

  1. download yiinitializr-advanced and install
  2. run php composer.phar self-update php composer.phar install
  3. set dev environment for command asking
  4. config db section in common/config/env/dev.php

when echo db variable in backend app, it shows 'connectionString' => 'sqlite:C:\wamp\www\test_web\common\config/../data/testdrive.db'

I actually insert mysql connectionstring in common/config/env/dev.php It's seem that common/config/env folder is ignored from merging configuration process.

please give me some advice. Thanks


Reply to this email directly or view it on GitHub: https://github.com/tonydspaniard/yiinitializr-advanced/issues/3#issuecomment-17926105

minkbear commented 11 years ago

I have deleted backend/config/env.php frontend/config/env.php console/config/env.php api/config/env.php

and also deleted env folder backend/config/env frontend/config/env console/config/env api/config/env

now I have only configs belows: common/config/env.php common/config/env/dev.php common/config/env/prod.php

but backend app unable to connect database which config in common/config/env/dev.php

Thanks.

tonydspaniard commented 11 years ago

Make sure you remove the config for db at the environment folders too.

And then run the composer install again. Before, delete the composer.lock file and vendor folder.

minkbear commented 11 years ago

OK.

I follow steps below as you mention and make sure that remove all the configs for db:

  1. Delete all files (env/*.php) for all folders (backend, frontend, console, api, common)
  2. Delete (backend, frontend, console, api, common) */config/env.php (remove all env.php)
  3. Delete composer.lock
  4. Delete all files in vendor folder
  5. Delete env.lock
  6. run php composer.phar install
  7. select dev for environment so on this stage, there is only a db config section in /common/config/main.php
  8. add db config section in /common/config/env/dev.php so on this stage, there are only 2 db config sections in 8.1 /common/config/main.php => sqlite 8.2 /common/config/env/dev.php => mysql
  9. navigate to backend app and echo db connection then it shows

'connectionString' => 'sqlite:C:\wamp\www\test_web\common\config/../data/testdrive.db'

Thanks.

minkbear commented 11 years ago

More info. I do var dump in Yiinitializr.config function. Below is output.

array(6) { [0]=> string(7) "backend" [1]=> string(59) "C:\wamp\www\test_web\backend\www/../../common/config/main.php" [2]=> string(58) "C:\wamp\www\test_web\backend\www/../../common/config/env.php" [3]=> string(60) "C:\wamp\www\test_web\backend\www/../../common/config/local.php" [4]=> string(3) "env" [5]=> string(5) "local" }

and look into Yiinitializr.build function. seem it does not merge common/config/env/.php or backend/config/env/.php

Thanks.

tonydspaniard commented 11 years ago

It does...

first the backend, then main, env, local, and last the env and local of backend config

Please, look for that connectionString to find out where is located

minkbear commented 11 years ago

OK

I already searched all connectionString in backend, frontend, console, api, common but there are 2 connectionString section surely. 1 /common/config/main.php => sqlite 2 /common/config/env/dev.php => mysql

then i try to var dump in Yiinitializr.build function. the result is shown below:

input parameters to Yiinitializr.build function

array(6) { 
[0]=> string(7) "backend" 
[1]=> string(59) "C:\wamp\www\test_web\backend\www/../../common/config/main.php" 
[2]=> string(58) "C:\wamp\www\test_web\backend\www/../../common/config/env.php" 
[3]=> string(60) "C:\wamp\www\test_web\backend\www/../../common/config/local.php" 
[4]=> string(3) "env" 
[5]=> string(5) "local" }

var dump in Yiinitializr.build function

string(88) "C:\wamp\www\test_web\common\lib\Yiinitializr\config/../../../../backend/config/backend.php" 
string(59) "C:\wamp\www\test_web\backend\www/../../common/config/main.php" 
string(58) "C:\wamp\www\test_web\backend\www/../../common/config/env.php" 
string(84) "C:\wamp\www\test_web\common\lib\Yiinitializr\config/../../../../backend/config/env.php" 

then look in deep in that function (Yiinitializr.build)

        foreach ($files as $file)
        {
            $config = file_exists($file) && is_file($file)
                ? require($file)
                : (is_string($file) && file_exists($directory . '/' . $file . '.php')
                    ? require($directory . '/' . $file . '.php')
                    : array());

            if (is_array($config))
                $result = ArrayX::merge($result, $config);
        }

above function is not look into common/config/ env/{ENVIRONMENT}.php or backend/config/ env/{ENVIRONMENT}.php

ex. common/config/env/dev.php

My yiinitializr-advanced is fresh installed. Do I need add more config for Yiinitializr, or not?

tonydspaniard commented 11 years ago

Lets get back to basics:

Try to have one single point connection string: at the common/config/main.php. Remove the others! There is no need to have multiple connectionstrings for backend or frontend atm.

Make sure you only have one connectionstring.

Once you find out it works, lets upgrade, that means, try to connect to different database config on your env.php file (the file created by composer install) for backend, and see if it overwrites the common.

minkbear commented 11 years ago

The key point is different environment make different database connection string. so i decided to save connection string in env/{ENVIRONMENT}.php ex. env/dev.php Example:

In dev environment the connection string should be in env/dev.php In prod environment the connection string sholud be in env/prod.php In test environment the connection string sholud be in env/test.php

How do you handle in this case? save connection string in env.php or dev.php? Please share your idea.

flyzard commented 10 years ago

Hi, Antonio,

I'm getting this error: Failed to clone https://github.com/doctrine/common.git via git, https protocols, aborting.

Can you help me on this please?

Thanks

tonydspaniard commented 10 years ago

@minkbear if i work with one database for both backend / frontend and we have different environments. We do configure common/config/env/{dev|prod|stage}.php, if we do have different DB for backend and/or frontend, then we place common configurations on common and databases on frontend|backend/config/env//{dev|prod|stage}.php and if I wish to test locally a different configuration, then I make use of local.php

@flyzard Thats an issue with composer. Try to update the phar file through php composer.phar self-update, then delete the vendor folder again and try it again... Sometimes it happens

iurquiza commented 10 years ago

If you are using MySQL, make sure you have the PHP mysql (PDO) extension installed.