Skip to content

Configuration Environments

ccapndave edited this page Apr 15, 2011 · 3 revisions

Flextrine has the concept of configuration environments which allow different configuration settings to be used based on the current environment. The following settings are valid for the environment:

  • development
  • test
  • staging
  • production

The effect of the environment setting is simply to tell Flextrine which yml configuration file to use in the application's config directory. For example, if your application is called myapp and the environment is set to development, Flextrine will use the configuration file at /myapp/config/development.yml.

Setting the environment

The environment can be set in the following ways (with highest priority first):

Via an environment variable

The recommended way to set the environment is via the FLEXTRINE_ENV environment variable (this needs to be set in such a way that it ends up in PHP's $_ENV or $_SERVER superglobal). This can be done via export, shell startup script, SetEnv in .htaccess, etc.

Via a GET parameter

You can pass the desired environment as a GET parameter to the gateway. For example:

configuration.gateway = "http://localhost/gateway.php?app=myapp&env=staging";

Via the default environment

If no environment is specified, Flextrine will use the default environment set in the main config.yml file. This defaults to development, so if you do nothing Flextrine will use the /<app>/config/development.yml file (this is also created by default).

Creating a new environment

Note that the flextrine app:create only creates the development.yml file by default. To use one of the other environments simply make a copy of development.yml in the same directory and rename it to staging.yml, test.yml or production.yml.