1

I am using codeigniter and git for this project.

Is it possible to create custom config files for each different developer and between develop and production branch. Because between develop and master branch we have different values for the database login credentials and other variables.

What I hope to achieved is at the config.php in the config folder, have something like $this->load->file('Developer_file')

where 'Developer_file' is the file for each different developer.

What I have now is just lumping all config variables in the config.php file in the config folder, just want to have a cleaner way of doing this.

2 Answers 2

3

I think environments are the way to go here. It is already built in CI so you won't need to make your own system.

I have a similar setup as yours I think: GIT+CI and multiple devs.

You can add as many as you want and easily create separate config files, such as database connections and paths. In your projects index.php you'll define the dev's or sites environments.

define('ENVIRONMENT', 'development');

So you will have a config folder structure like this:

/application
    /config
        /development
        /other-dev
        /staging
        /production

Watch out if you use git that you don't include the index.php in your repo (or at least not with that name). You'll have to upload that one manually.

Sign up to request clarification or add additional context in comments.

3 Comments

this looks good. so for the index.php i have to git ignore it then?
i'd recommend it yes. otherwise you'll keep overriding each others index files. Since they are the once defining which specific environment you are in.
You could always keep a copy of the index file in the repo under a different name. eg: index_copy.txt That way you can copy that file and rename it when you install your app in a different location.
0

You can try some think like this:

  1. Add different config files to config folder.

  2. Define in index.php some constant, something like this define('DEVELOPER_TYPE', 'developer');

  3. Change config/autoload.php. Something like this:

    switch(DEVELOPER_TYPE){
        case 'developer':
            $autoload['config'] = array('developer_config');
            break;
        case 'tester':
            $autoload['config'] = array('tester_config');
            break;
    }
    

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.