Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. # Settings
  2.  
  3. - Organized into groups located in `site/settings/[group].yaml`
  4. - These various files map to pages in the CP under `System > Settings`
  5.  
  6.  
  7. ## Addon settings
  8.  
  9. Each addon can have their own settings file located in `site/settings/addons/addon_name.yaml`.
  10.  
  11. Addon settings can be overridden in your environment files. See below for more details.
  12.  
  13.  
  14. ## Environment Specific Settings
  15.  
  16. Sometimes is beneficial to have different settings depending on where you are running the site. For instance, enabling debug mode when in development, but not in production.
  17.  
  18. ### The `.env` file
  19.  
  20. The `.env` contains environment level variables. These can be used within Statamic settings files and are also used to change Statamic's behavior.
  21.  
  22. The syntax in this file is:
  23.  
  24. ```
  25. MY_VARIABLE=value
  26. DELICIOUSNESS=bacon
  27. ```
  28.  
  29. Your `.env` file should _not_ be committed to version control, since it may contain confidential information, and since each developer / server could require a different environment configuration.
  30.  
  31. If you are developing with a team, you may wish to continue including a `env.example` file. By putting placeholder values in the example file, other developers on your team can clearly see which environment variables are needed to run the site.
  32.  
  33. ### Defining Environments
  34.  
  35. By default, Statamic runs in the `production` environment.
  36.  
  37. To specify a different environment, add `APP_ENV=foo` where `foo` is the name of your environment.
  38.  
  39. ### Environment settings
  40.  
  41. There are two options when it comes to environment-specific settings. You can mix-and-match them. Whatever feels natural to you.
  42.  
  43. #### Option 1: Interpolation
  44.  
  45. The first option is to add the `.env`-based variables directly into settings files using the `{env:}` helper.
  46.  
  47. For example, in `debug.yaml`, you could do this:
  48.  
  49. ``` .language-yaml
  50. debug: "{env:APP_DEBUG}"
  51. ```
  52.  
  53. and set `APP_DEBUG=true` in your `.env` file.
  54.  
  55. You may use the variable in the middle of a string, for example:
  56.  
  57. ``` .language-yaml
  58. greeting: "Hello {env:NAME}"
  59. ```
  60.  
  61. ```
  62. NAME=ron
  63. ```
  64.  
  65. Note: When interpolating, make sure to wrap your value in quotes.
  66.  
  67. #### Option 2: Environment files
  68.  
  69. The second option is to leverage the environment settings file.
  70.  
  71. Statamic will load `site/settings/environments/foo.yaml` where `foo` is the current environment.
  72.  
  73. In here, any variables are added to the cascade.
  74.  
  75. For instance:
  76.  
  77. ``` .language-yaml
  78. settings:
  79. debug:
  80. debug: true
  81. debug_bar: true
  82. addons:
  83. bacon:
  84. slices: 20
  85. ```
  86.  
  87. Anything nested under `settings` would override values in the corresponding yaml file. So in this example, `debug` and `debug_bar` will override the values in `debug.yaml`.
  88.  
  89. Anything nested under `addons` would override values in the corresponding addon's yaml file. So in this example, `slices` would override the value in the `bacon` addon's setting file.
  90.  
  91. You can also interpolate in your environment files, if you wish.
  92.  
  93. ``` .language-yaml
  94. settings:
  95. debug:
  96. debug: "{env:APP_DEBUG}"
  97. ```
  98.  
  99. #### Editing environment settings
  100.  
  101. When an environment setting has been used, it becomes uneditable through the control panel. This prevents confusion on where the value is coming from.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement