CodeIgniter Forums
CodeIgniter and Git, how to manage config files. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: CodeIgniter and Git, how to manage config files. (/showthread.php?tid=49475)



CodeIgniter and Git, how to manage config files. - El Forum - 02-21-2012

[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.




CodeIgniter and Git, how to manage config files. - El Forum - 02-21-2012

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

http://ellislab.com/codeigniter/user-guide/general/environments.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');



CodeIgniter and Git, how to manage config files. - El Forum - 02-21-2012

[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.


CodeIgniter and Git, how to manage config files. - El Forum - 02-21-2012

[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


CodeIgniter and Git, how to manage config files. - El Forum - 02-21-2012

[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.


CodeIgniter and Git, how to manage config files. - El Forum - 02-21-2012

[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 ^^


CodeIgniter and Git, how to manage config files. - El Forum - 02-21-2012

[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-control/video-101-getting-started-with-git.aspx

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


CodeIgniter and Git, how to manage config files. - El Forum - 02-21-2012

[eluser]ilovekhym[/eluser]
@CroNiX - thanks Smile


CodeIgniter and Git, how to manage config files. - El Forum - 02-28-2012

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