Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

In a config file for a PHP project, I have some settings that should not go out in production. Can anybody offer some specific examples or help on how to automatically check these fields and make sure their values are not the development/demo settings before the files get committed into subversion?

Our IDE is JetBrains PHP Storm, and we use the latest version of subversion. Some of us develop on Linux, while others are on Windows.

share|improve this question

closed as not constructive by gnat, Martijn Pieters, Walter, MichaelT, Kilian Foth Mar 24 '13 at 17:44

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

4 Answers

up vote 7 down vote accepted

This shouldn't be handled by SubVersion but by build script.

This script should modify or replace development settings into production one during the release process (if automated).

share|improve this answer
add comment

We use a sample config file which is added to the repository. The used config file is ignored by subversion and will/can be changed by every developer. If the developer adds something there, he must add the default value to the sample, too.

Changes to the config file used in the productive system has to be done by hand. To enforce that the production config get the changes that are necessary, we have created a checklist for the deploy process which needs to be followed. The deploy is done by a pair of developer, just to make sure we have 4 eyes on the process...

share|improve this answer
add comment

I have a configuration directory with one subdirectory for each sort of installation, e.g. development, demo, production, test, etc. Deployment of a new version is done in three steps:

  1. Checkout

    svn co ...

  2. Configure and build

    ant configure -Dconfiguration=production

    This copies files from the configuration subdirectory into the appropriate location, and builds the application

  3. Install

    cp myapp ...

share|improve this answer
add comment

Well, this answer is correct, this isn't a job for the SCM.

But, in reality we all put up with stuff that's not ideal so... what you want is to put a call to grep in your pre-commit hook (or a perl script that does a regex). You must pay particular attention to getting your regex unique to the config files, even to the point of only checking those files with the relevant names. (otherwise you may end up rejecting a perfectly good file - some documentation for example)

If the regex matches lines that only exist in your dev/demo config files, then write a quick error message to stderr and return 1. SVN will handle the rest for you.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.