0

I am working with phpfog. I use git to push my code to phpfog. My problem: I have config-passwords.txt with my local passwords and user names, i have other passwords and user names in production. Usually i upload manually to server the configs files and then change them, but i dont see that phpfog gives such option.What should I do?

Thanks

Ben
  • 23,101
  • 33
  • 104
  • 161

1 Answers1

1

One way to allow for different settings or passwords between your development and production environments is to use environment variables. PHP Fog allows you to configure custom environment variables in the app console. You would then set the same envars on your dev system.

Example:

Local Machine: Edit your .bash_profile or export the following line.

CONFIG_PASSWORD=devpassword1

In the PHP Fog App Console set the following environment var:

CONFIG_PASSWORD=prodpassword1

Then access them from your php app:

$config_password = getenv("CONFIG_PASSWORD");

Add as many different env vars as you need. This way of accessing the password will work the same in both dev and production environments so your code does not need to change.

See my answer to a similar question: https://stackoverflow.com/a/8786086/78685

Community
  • 1
  • 1
Tim Santeford
  • 24,045
  • 13
  • 70
  • 98
  • thanks, but why you not give just upload file manually and change it manually on production? – Ben Aug 09 '12 at 17:34
  • is exis other way to do it in phpfog? – Ben Aug 09 '12 at 17:50
  • There is another way but its very cumbersome and requires having multiple branches and merging prior to pushing to phpfog. I bet my above solution will actually be simpler to code and faster then loading up a file to get settings each page load. Try it, this is the recommended way of doing it. – Tim Santeford Aug 09 '12 at 18:29
  • i try it works on phpfog, but in my local ubuntu not working var_dump(getenv("some_var")) === false , should i change .bash_profile permissions? – Ben Aug 09 '12 at 18:32
  • Did you try export? `export CONFIG_PASSWORD=devpassword1` – Tim Santeford Aug 09 '12 at 18:52
  • I would check if `some_var` shows up in phpinfo() on your local system. If it is shown then there maybe a code issue. Also just try to echo out the value for testing. I think var_dump(getenv("some_var")) === false would never evaluate true because some_var will be of type string not boolean. – Tim Santeford Aug 09 '12 at 20:52
  • Also you could try restarting your apache web server. – Tim Santeford Aug 09 '12 at 20:59
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/15186/discussion-between-tim-santeford-and-yosef) – Tim Santeford Aug 10 '12 at 17:16