Answers.Body: <p>If you add it after you load the dot env stuff in your public index.php file, it should work:</p>
  
  <pre><code>// Load dotenv?
  if (file_exists(CRAFT_BASE_PATH.'/.env')) {
      (new Dotenv(CRAFT_BASE_PATH))-&gt;load();
  }
  
  define('CRAFT_TEMPLATE_PATH', getenv('CRAFT_TEMPLATE_PATH'));
  
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-14T12:25:47.390Z
Answers.Text: I had assumed that my be a bad idea after the autoload but it was still throwing an error. But could be my stack issue. Will take another look
Answers.UserDisplayName: joomkit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-13T23:48:37.173Z
Answers.LastActivityDate: 2019-02-13T23:48:37.173Z
Answers.UserDisplayName: Brad Bell
Body: <p>It appears on Craft 3.1.8 that I can't set the CRAFT_TEMPLATE_PATH from .env without throwing a PHP notice error. This appears to be because the .env is loaded after the defines and I want to access the .ENV for my CRAFTENV_template path.</p>
  
  <p>How can I set CRAFT_TEMPLATE_PATH from my .env without producing an error/warning?</p>
  
Tags: <config><environmentvariables>
Title: Allowing CRAFT_TEMPLATE_PATH in index.php from .env variable
ThreadText: # Allowing CRAFT_TEMPLATE_PATH in index.php from .env variable
  
  (Asked by: username_0 on 2019-02-13)
  
  It appears on Craft 3.1.8 that I can't set the CRAFT\_TEMPLATE\_PATH from .env without throwing a PHP notice error. This appears to be because the .env is loaded after the defines and I want to access the .ENV for my CRAFTENV\_template path.
  
  How can I set CRAFT\_TEMPLATE\_PATH from my .env without producing an error/warning?
  
  **Tags:** config, environmentvariables
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-02-13. Score: 0
  
  If you add it after you load the dot env stuff in your public index.php file, it should work:
  
  ```
  // Load dotenv?
  if (file_exists(CRAFT_BASE_PATH.'/.env')) {
      (new Dotenv(CRAFT_BASE_PATH))->load();
  }
  
  define('CRAFT_TEMPLATE_PATH', getenv('CRAFT_TEMPLATE_PATH'));
  
  ```
  
  > **Comments:**
  > **username_0**: I had assumed that my be a bad idea after the autoload but it was still throwing an error. But could be my stack issue. Will take another look  
  
  ---
  
  