CodeIgniter and Git, how to manage config files.

#1
[eluser]Bramme[/eluser]
I'm using Git for the first time to manage my app development. I have my origin repository on a remote server, but I develop locally. Everytime I push to the origin repository, I also do a checkout so I can test the project online.

This means my config.php is different between the online version and the local version. I'm completely new to Git though, and don't really know what's the best approach to handle this.

I found this page: https://gist.github.com/1423106 and like the idea of providing a config.sample.php file, but was wondering if other people had more elegant solutions.


#2
[eluser]porquero[/eluser]
You must use:

http://ellislab.com/codeigniter/user-gui...ments.html

In resume you must create different config files by environment:

/application/config/ENVIRONMNET

Ex:

/application/config/development/config.php
/application/config/production/config.php

So when you set environment, CI load their file:

Code:
define('ENVIRONMENT', 'development');

#3
[eluser]Bramme[/eluser]
But that still means I have to change the ENVIRONMENT constant between local and remote and also means my development config files will be in my Git repo. Since I plan on making this thing public sooner or later, I'm guessing that's not what I want.

#4
[eluser]porquero[/eluser]
So is more easy. Ignore file when commit.

You can create a sample config like you say and commit it, and ignore that you use.

Another example is the config file for phpMyAdmin: config.inc.php-dist

For "activate" it in the installation, you must copy the file and rename to config.inc.php

#5
[eluser]CroNiX[/eluser]
@Bramme, in your index.php, just define the environment based on $_SERVER['HTTP_HOST'] with a default of 'production' (most restrictive error reporting etc) so it's dynamic. This is what the ENVIRONMENT is designed for and makes life a lot easier.

I use git on all projects and this works great! If you are worried about development files in the repo, you can use .gitignore and don't include them in git. Also, you can use a private repo for development and only push things to a public repo when they are stable, so no one will ever see that stuff. Or, use stable/development branches where the public only has access to the stable branch.

#6
[eluser]Bramme[/eluser]
[quote author="CroNiX" date="1329845608"]@Bramme, in your index.php, just define the environment based on $_SERVER['HTTP_HOST'] with a default of 'production' (most restrictive error reporting etc) so it's dynamic. This is what the ENVIRONMENT is designed for and makes life a lot easier.

I use git on all projects and this works great! If you are worried about development files in the repo, you can use .gitignore and don't include them in git. Also, you can use a private repo for development and only push things to a public repo when they are stable, so no one will ever see that stuff. Or, use stable/development branches where the public only has access to the stable branch.[/quote]

Hmm, that sounds really good. I'm really new to git (started with it yesterday), so I'm not too familiar with branches, but that sounds like a fun workflow, I'm gonna try it out ^^

#7
[eluser]CroNiX[/eluser]
No prob! I'd check these out:
Article: http://nvie.com/posts/a-successful-git-branching-model/
Videos: http://ava.co.uk/support/faq/git-version...h-git.aspx

I'd watch the vids on youtube though (in 1080p, just add to your playlist). It's just a lot clearer.

#8
[eluser]ilovekhym[/eluser]
@cronix - thanks Smile

#9
[eluser]Unknown[/eluser]
Thanks for the discussion...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.