Welcome Guest, Not a member yet? Register   Sign In
.gitignore file for CodeIgniter 3
#1

(This post was last modified: 08-19-2015, 10:30 AM by izaban.)

Hi there,

Is the following .gitignore file published in https://github.com/github/gitignore/blob....gitignore an acceptable one?

*/config/development
*/logs/log-*.php
!*/logs/index.html
*/cache/*
!*/cache/index.html
!*/cache/.htaccess

I've received the advice that I should include the user_guide and system directory in case I want to update CodeIgniter in the future. Also the application/config directory because contains plataform specific files. What is your advice about the .gitignore file?
Reply
#2

https://github.com/bcit-ci/CodeIgniter has its own .gitignore file, which is more appropriate.

A good practice is to keep the framework (the above project) separate from any app, and to reference its system folder location in your app's index.php. You can then share the framework across apps, and update the framework without affecting your apps.

What you are referring to in your post is the .gitignore file from the github repositories, presumably a default one.
Check the .gitignore in our project.
Reply
#3

What about the application/config directory? Should I .gitignore only the plataform specific files (e.g. database.php)?
I found the following question in stackoverflow http://stackoverflow.com/questions/18115...odeigniter where the suggestion is using an environment directory inside config directory for these files. Also I've received the advice from a colleague that I should .gitignore the entire application/config directory, but this seems weird because I don't feel confortable by ignoring the routes.php file for instance. What is the best practice about this?
Reply
#4

(07-23-2015, 07:33 AM)izaban Wrote: What about the application/config directory? Should I .gitignore only the plataform specific files (e.g. database.php)?
I found the following question in stackoverflow http://stackoverflow.com/questions/18115...odeigniter where the suggestion is using an environment directory inside config directory for these files. Also I've received the advice from a colleague that I should .gitignore the entire application/config directory, but this seems weird because I don't feel confortable by ignoring the routes.php file for instance. What is the best practice about this?

There's a method built-into the framework and that's the environment-specific configs. You won't get closer to a "best practice" than that because that's the most flexible solution, but it's natual that you'll get different advices from different people - the whole problem here is that every environment is unique and there's no magic bullet. You just have to pick what works for you.
Reply
#5

The main thing to remember is to exclude files generated by code, like logs, cache files, and database backups. Other items to consider are those which should only exist in development, which you should track in a separate repository, like tests and installation scripts. If you use Composer, you probably want to exclude the vendor directory, and possibly composer.lock (depending on how you're using Composer).

Excluding the development config files (application/config/development/*) from source control is a good idea when working with other developers, but the config directory itself should be in source control so everyone is starting from the same baseline.

If there's some concern about the production configs being in source control, or the developers being able to change config files that may cause problems with the production environment, then exclude the specific files and put the production files under separate version control. Most of the time, there probably won't be that much to worry about other than the database config.

You may want to consider excluding a few other files that show up when using other tools or multiple operating systems, like these (the format may be slightly different, since I primarily use Hg):

Code:
*.DS_Store
*Thumbs.db
*.bak
.hg/*
*.sublime-project
*.sublime-workspace
Reply




Theme © iAndrew 2016 - Forum software by © MyBB