Strategy with using SVN to switch between test and production server. (with maintaining configuration files) [closed]

softwareengineering.stackexchange https://softwareengineering.stackexchange.com/questions/207391

سؤال

I would like to know your opinion about my setup right now, how I do things with SVN and if you could find some better solution for me. I'd appreciate it very much if someone could come up with some better solutions for my problems. I would like to do it the best way possible and the most efficiently.

My situation is as follows: I'm maintaining a PHP website which is connected to mysql database. I have a subdomain on which I'm testing everything. There are also two databases: first for testing purposes, second for the production server. I have a project in Netbeans and I'm connected to ftp with it so every change I make is directly transferred to the website. Also I'm connected to SVN server and the testing part of the website is in trunk directory. Every time I want to upload the changes to the server I'm commiting my trunk and then I'm copying it to tags. After that I got another project in Netbeans prepared, already connected to the same SVN, but to the last tag copy. After I copy the trunk to tag directory, I switch to the second project and switch to the newest version in tags. Now I have in some another directory every configuration file prepared in proper directory structure - I copy it to my production project. After that I click "Run" in Netbeans and that opens a window which allows me to accept the transfers to the sftp, but this time to the production part of the website.

My question is: is it the best way? Aren't there any more intuitive tools or options in SVN, so I don't have to copy the configuration files every time?

هل كانت مفيدة؟

المحلول

A software package has two kinds of configuration:

  1. environment-specific configuration
  2. behaviour-specific configuration

The former differs between the devel, test, stage and production environments. It should have at most 4 lines or so (web server base url, database connection string, SSL certificates, connection strings/urls to other related components, installation directory, authentication realm and such; you rarely need most of those even) and since it makes absolutely zero sense outside this installation on the particular server (i.e. it may change when the server is reinstalled), it should generally not be versioned (except as part of versioning the server installation if your admin is into that).

The later should be versioned all right, but must not differ between the environments. It's just part of the source/build.

Obviously the configuration needs to be appopriately split across two files so you can version the one you need and not the other one.

نصائح أخرى

A simple solution would be to keep all the configuration files in the repo and the have a build script that copies the correct version for the environment in when needed.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى softwareengineering.stackexchange
scroll top