Cake 2.x Environment Variables and database.php file.

So I'm trying to horseshoe an existing Cake 2.x application running on Ubuntu 14.04 into a docker container. I'm pretty sure there's better ways of doing it, but I'm basically just trying to replicate what I have inside a docker container.

The one big change though is environment variables. When the container launches, a config file gets pulled in and some environment variables set. These variables have to be used in various configuration files for the cake application. I set them in the /etc/apache2/sites-enabled/default.conf file with there "SetEnv" directive. I also "export" each variable and it all seems to be working fine. I use the "getenv()" method to get each of the variables into my config files.

The problem I seem to have is using environment variables in the database.php file. I've tried both pulling the variable directly from the environment with "getenv()" and setting it in my environment_settings.php file with "Configure::write()" and then using "Configure::read()" in the database.php file, but neither of these methods work.

Is there a reason why this is happening? And what can I do to fix this?

Exit mobile version