Skip to content

Instantly share code, notes, and snippets.

@jmikola
Created September 2, 2010 21:26
Show Gist options
  • Save jmikola/562975 to your computer and use it in GitHub Desktop.
Save jmikola/562975 to your computer and use it in GitHub Desktop.
Suggestions for organizing Symfony2 app configs

Some rules

Configs exist in three levels:

  1. local
  2. dev | stg | prod
  3. default (no environment)

There are three types of configs:

  1. Application-level
  2. Global-level
  3. Global-level, but feature-specific (e.g. api_router)

Application-level configurations should start off by including their logical parent, applicational-level config, followed by their global-level configuration and/or any global, feature-specific configs (if applicable). Global-level configurations should not include logical parents, since application-level configs do that, but they may include global, feature-specific configs.

app/config/config_local.yml (8) imports:
 * app/config/dev.yml (5), which imports:
   * app/config/config.yml (2), which imports
     * /config/config.yml (1)
   * /config/config_dev.yml (4), which imports:
     * /config/dev/api_router.yml (3)
 * /config/local.yml (7), which imports
   * /config/local/api_router.yml (6)

The numbers beside each file indicate the order in which their contents will be processed. Alternatively:

  1. /config/config.yml
  2. app/config/config.yml
  3. /config/dev/api_router.yml
  4. /config/config_dev.yml
  5. app/config/dev.yml
  6. /config/local/api_router.yml
  7. /config/local.yml
  8. app/config/config_local.yml

The rule of thumb is lowest level first, and for each level, global before application.

@bobthecow
Copy link

exception worth noting: only apps with guis include the global config. reporting, cas, etc do not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment