Answers.Body: <p>Alright, so turns out all I need to do is comment out the following line in index.php:</p>
  
  <pre><code>define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
  </code></pre>
  
  <p>Now I can use config.php keys, same way I did in Craft 2. For example:</p>
  
  <pre><code>'*' =&gt; [
      // My default/production variables
      'devMode' =&gt; false,
      etc...
  ],
  // Local
  'address.test' =&gt; [
      // Local variables
      'devMode' =&gt; true,
      etc...
  ]
  // Staging
  'staging.address.com' =&gt; [
      // Staging variables
      'devMode' =&gt; true,
      etc...
  ]
  </code></pre>
  
  <p>Thanks to Luke James for the assist on Slack.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-01T10:16:37.010Z
Answers.LastActivityDate: 2018-06-01T10:16:37.010Z
Answers.UserDisplayName: Ian Ebden
Body: <p>Morning folks. First time doing multi-environment in Craft 3, and separate installations for staging and production is a bit overkill for this particular project. Instead I just want to show a few new bits in templates on the staging subdomain until sign-off.</p>
  
  <p>Staging domain (<a href="https://staging.adddress.com" rel="nofollow noreferrer">https://staging.adddress.com</a>) is pointed at the production 'public' directory. So in Craft 2, I'd just let the 'staging' key in my config.php set all the necessary environment variables. But in Craft 3 don't I need to load the correct .env first? Since it's all the same installation, is there a way to switch to .env.staging when on the staging subdomain? Is that the correct/best approach? Thanks.</p>
  
Tags: <craft3><multi-environment>
Title: Multi environment-lite
ThreadText: # Multi environment-lite
  
  (Asked by: username_0 on 2018-06-01)
  
  Morning folks. First time doing multi-environment in Craft 3, and separate installations for staging and production is a bit overkill for this particular project. Instead I just want to show a few new bits in templates on the staging subdomain until sign-off.
  
  Staging domain (<https://staging.adddress.com>) is pointed at the production 'public' directory. So in Craft 2, I'd just let the 'staging' key in my config.php set all the necessary environment variables. But in Craft 3 don't I need to load the correct .env first? Since it's all the same installation, is there a way to switch to .env.staging when on the staging subdomain? Is that the correct/best approach? Thanks.
  
  **Tags:** craft3, multi-environment
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-06-01. Score: 1
  
  Alright, so turns out all I need to do is comment out the following line in index.php:
  
  ```
  define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
  
  ```
  
  Now I can use config.php keys, same way I did in Craft 2. For example:
  
  ```
  '*' => [
      // My default/production variables
      'devMode' => false,
      etc...
  ],
  // Local
  'address.test' => [
      // Local variables
      'devMode' => true,
      etc...
  ]
  // Staging
  'staging.address.com' => [
      // Staging variables
      'devMode' => true,
      etc...
  ]
  
  ```
  
  Thanks to Luke James for the assist on Slack.
  
  
  ---
  
  