Tuesday, 22 November 2016

How to implement different configs for development, production?

How to implement different configs for development, production?

Question: How to implement different configs for development, production etc?
  1. Added following line in .htacess (Location: /public/.htaccess)
    SetEnv APPLICATION_ENV development
    This is for development.
  2. Open application.config.php in /config/application.config.php
  3. Get the current environment.
    $applicationEnv = getenv('APPLICATION_ENV');

    Dynamic the file like below:
            'config_glob_paths' => array(         
                "config/autoload/{,*.}{$applicationEnv}.php"
            )
  4. Create the config files like below in /config/autoload
    development.php
    production.php
    
  5. Below are the sample of config file.
    return array(
        'db' => array(
            'driver' => 'Pdo',
            'dsn' => 'mysql:dbname=DBNAME;host=HOST',
            'username' => 'DB_USERNAME',
            'password' => 'DB_PASSWORD'
        )
    );
    Please update the database credentials.

1 comment :

preethi Sharma said...

Hi There,

Thank you! Thank you! Thank you! Your blog was a total game changer!

In my current project, I need to develop a UI which contains 4 different dropdown or select controls data of which will be populated from web api methods. I call 4 different http.get method for 4 dropdown control. But issue is that when I run the page, all dropdown data not populated properly. Some times, dropdown1 data bind in dropdown3. I don't understand the reason of this issue.
Thanks a lot. This was a perfect step-by-step guide. Don’t think it could have been done better.

Obrigado,
Janani

Post a Comment