Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separating CodeIgniter config file Git for publishing publically

I am about to start a CodeIgniter based project and plan on using Git as our DVCS. I will be working with a few other developers, and the central (origin) server is privately hosted. But I also want to open source it and publish the code to Github later.

My question is, is there a way to separate the config file(s) in Git, so that the private information in the config file is not sent to the Github remote but is to origin and other peers.

Another question is could we use a similar solution for having local development config files and a server one for production?

like image 717
Alex Stuckey Avatar asked Apr 20 '12 21:04

Alex Stuckey


2 Answers

Create the files config.php.sample and database.php.sample that each of your developers will use that has a placeholder for the passwords and other sensitive information. Add config.php and database.php to your .gitignore

The first time you deploy to the production site, you'll create the config.php and database.php files. Subsequent pushes won't overwrite config.php and database.php since they're not included in the git repository.

like image 56
dwilkins Avatar answered Oct 03 '22 20:10

dwilkins


Codeigniter has some support for environments (Development, Production, etc). Refer to official documentation , CodeIgniter Environments.

Regarding config files, you can use .gitignore

http://progit.org/book/ch2-2.html

Edit: Since you have used github tag in the question; Github now has an option to add .gitignore file (they have a codeigniter template too )

like image 35
Vamsi Krishna B Avatar answered Oct 03 '22 18:10

Vamsi Krishna B