3

I am doing a Laravel 4 project, and there is an option on mail.pjp, where you can pretend to send an email, but you actually are logging it locally into a file. This is useful for development.

The problem I have is with version control. If I check in, this option as "true", then I risk that when I update the production server, it might disable emails if I am not careful.

On the other hand, if I check in the file in git as "true", it might happen what happened today, that I lost a good couple of hours trying to understand why the mail was not working because I forgot I had to change this option for my development environment.

What way could I handle these "production vs development" configuration issues with git?

7

2 Answers 2

2

Have a branch for each configuration.

For instance, you could have a production branch and a dev branch.

On the production branch, just make one commit to change the configuration file, then use the dev branch the same way you used your master branch.

The deployment process becomes

On dev:

  • git checkout production
  • git merge dev
  • git push origin production

On production:

  • git pull origin production

Or split your configuration file

And maybe add some runtime test to pick the good one at the right time.

Sign up to request clarification or add additional context in comments.

1 Comment

Just to be sure, those 3 commands that you write, should I type them on the dev machine, or in the production server?
1

I have a similar problem and use the following solution which might be a bit heavy but works well to separate 'private' data from a public project.

The idea is to not put your configuration file under your normal git repository but in an a private one. Ideally you would like the private repo to be a submodule of the public one, but you have to do it the other way (to hide the private repo from the public one).

For this, I create a private repo which contains my configuration file. then I create a submodule containing the public one and add a link to the configuration file.

The directory structure looks like :

private + (private git repo) | +- config.conf | +- public + (public git repo) | + config -> ../config.conf | + src 

Then I have a devel and a production branch on the private repo with the two version of the configuration file. But I never really touch those directory.

When a new developper arrives he just forks the devel branch and the works inside the public as if there is no umbrella project. Just pull push as normal.

When you need to deploy just go on the production machine and update the public submodule. If you need to update the production configuration file, just update it on the production machine and push it. Alternatively you can switch locally to the production branch, make the necessary changes and push them to the production server.

Hope it's clear.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.