josegonzalez / rad-cakephp-2

Issue Tracker for the "Rapid Application Development with CakePHP 2" BOOK
http://josediazgonzalez.com/cakephp-book/
3 stars 1 forks source link

Changes in .env file is ignored #10

Closed sunfffd closed 10 years ago

sunfffd commented 10 years ago

I have created a .env file and changed the settings inside. Everything is fine except the database connection string. Even if I change them, the cake engine is still loading the default one (database = database_name). Looks like it cannot be overwritten somehow.

However if I change DATABASE_URL to DATABASE_URL1 and update it in Config/database.php, it loads the config correctly.

josegonzalez commented 10 years ago

Can you try removing your .env.default file?

sunfffd commented 10 years ago

Hi Jose,

I removed the .env.default file, however that configuration still exist when I view in the the DebugKit's Environment tab.

josegonzalez commented 10 years ago

Is this within your vm? Or on heroku? If it's in the vm, the env vars are set from a fastcgi_param in nginx...

sunfffd commented 10 years ago

It is in my VM, I tried setting fastcgi_param too but with no prevail. Thing is the other parameters in the .evn file (e.g. DEBUG, SECURITY_SALT..etc) are retrieved correctly by CakePHP, it's only the DATABASE_URL and DATABASE_TEST_URL being ignored.

josegonzalez commented 10 years ago

Hmmm let me try and replicate the issue.

Why are you changing your db config within the vm?

sunfffd commented 10 years ago

Correct me if I'm wrong here:

The original .env file's DATABASE_URL is something like export DATABASE_URL="mysql://root:bananas@localhost/database_name?encoding=utf8"

Actually I just want to change the database name, as in export DATABASE_URL="mysql://root:bananas@localhost/name_of_my_database?encoding=utf8"

Should I change it else where? thanks!

josegonzalez commented 10 years ago

No that should be fine. When you changed it in the fastcgi_params, did you also change it in your .env files? And did you restart the vm?

sunfffd commented 10 years ago

In my /etc/nginx/fastcgi_param there are original no DATABASE_URL and DATABASE_TEST_URL params.

I added something like fastcgi_param DATABASE_URL "mysql://root:bananas@localhost/dbname?encoding=utf8"; fastcgi_param DATABASE_TEST_URL "mysql://root:bananas@localhost/test_dbname?encoding=utf8";

these also exists in .evn file.

Then I reloaded nginx config file in vagrant with sudo nginx -s reload

josegonzalez commented 10 years ago

It's specified in the vhost, sorry.

sunfffd commented 10 years ago

Ok I changed that from the default vhost file, it's working now :)