CodeIgniter Forums
Database-sample.php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: Database-sample.php (/showthread.php?tid=72841)



Database-sample.php - vitalykk1983 - 02-18-2019

I just interesting in one question, sorry, if it's duplicate thread, but I can't find answer.

I can't understand, why CI don't have a file database-sample.php, like others frameworks. And file database.php must be in .gitignore by default, IMHO.  It's easy to have two file database-sample.php and database.php, so why not?


RE: Database-sample.php - ciadmin - 02-18-2019

What do understand a "database-sample.php" to contain?
"database.php" would normally be git-ignored because we expect it to hold database access credentials.


RE: Database-sample.php - vitalykk1983 - 02-18-2019

For example, laravel has two files .env and .env.example, where .env contains real database credentials, email settings, etc and .env.example contains standard fake data only for sharing purposes. If I download a repository I can quickly setup project, using .env.example and then rename it to .env.
It's good approach in laravel, so I just ask what do you think about it


RE: Database-sample.php - ciadmin - 02-18-2019

Hmmm - isn't application/config/database.php pretty much what you described?
And the user guide (https://www.codeigniter.com/user_guide/database/configuration.html) goes into more details.

As it is, you only need to create an environment-specific folder underneath aplicaiton/config, and copy then tailor any config files (eg database). You might have to make sure to git ignore them.

We have done this with CodeIgniter 4, with sample files to customize (.env, phpunit.xml.dit, Vagrantfile.dist), with the tailored files already git ignored.


RE: Database-sample.php - vitalykk1983 - 02-19-2019

Codeigniter version 4 looks very and very promising. So wait for stable release Smile and thanks for all contributors for their work making the CI better