Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install issue #3

Open
algebris opened this issue May 1, 2013 · 14 comments
Open

Install issue #3

algebris opened this issue May 1, 2013 · 14 comments
Labels

Comments

@algebris
Copy link

algebris commented May 1, 2013

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
Copy link
Owner

@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
Copy link

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
Copy link
Owner

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:
#3 (comment)

@minkbear
Copy link

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
Copy link
Owner

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
Copy link

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
Copy link

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
Copy link
Owner

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
Copy link

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
Copy link
Owner

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
Copy link

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
Copy link

flyzard commented Aug 7, 2013

Hi, Antonio,

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

  • git://github.com/doctrine/common.git
    sh: line 0: cd: /path/to/project/advanced/common/lib/vendor/doctrine/common: No such file or directory

Can you help me on this please?

Thanks

@tonydspaniard
Copy link
Owner

@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
Copy link

iurquiza commented Apr 4, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants