Answers.Body: <p>There is a really nice <a href="http://craftcookbook.net/recipes/273" rel="nofollow noreferrer">multi-environment configuration</a> method defined on the craft cookbook website, that creates a global php variable called <code>CRAFT_ENVIRONMENT</code> in your main <code>index.php</code>. It seems to me that you could also use this global to define the <code>$craftPath</code>.</p>
  
  <pre><code>switch (CRAFT_ENVIRONMENT) {
      case "dev":
          $craftPath = '../craft';
          break;
      case "stage":
          $craftPath = '../../craft';
          break;
      default:
          // default "production"
          $craftPath = '../../craft';
  }
  </code></pre>
  
  <p>I generally use the above method (without the new switch part) in combination with <a href="https://craftcms.stackexchange.com/questions/4728/how-to-set-up-siteurl-to-work-with-both-http-and-https/4734?s=1%7C0.1884#4734">this configuration method</a> in my <code>general.php</code> config file.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-02-01T17:55:20.027Z
Answers.LastActivityDate: 2015-02-01T17:55:20.027Z
Answers.LastEditDate: 2017-04-13T12:51:00.253Z
Answers.UserDisplayName: Douglas McDonald
Body: <p>I am new to Craft and am trying to figure out what the best way to set the <code>$craftPath</code> PHP variable to something like the other configurations for multi-environments.</p>
  
  <p>Locally I have it set up the preferred way, but on my remote server, it's nested an extra level deep in folders (sub domains).</p>
  
  <p>Is there a way to have the variable be set using the same functionality that Craft uses to determine environments? Or do I have to just manually change the value where the index.php lives.</p>
  
  <p>Thanks for the advice.</p>
  
Tags: <config><variable><craft-features>
Title: $craftPath multiple enviroments
ThreadText: # $craftPath multiple enviroments
  
  (Asked by: username_0 on 2015-02-01)
  
  I am new to Craft and am trying to figure out what the best way to set the `$craftPath` PHP variable to something like the other configurations for multi-environments.
  
  Locally I have it set up the preferred way, but on my remote server, it's nested an extra level deep in folders (sub domains).
  
  Is there a way to have the variable be set using the same functionality that Craft uses to determine environments? Or do I have to just manually change the value where the index.php lives.
  
  Thanks for the advice.
  
  **Tags:** config, variable, craft-features
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-02-01. Score: 2 | Accepted answer
  
  There is a really nice [multi-environment configuration](http://craftcookbook.net/recipes/273) method defined on the craft cookbook website, that creates a global php variable called `CRAFT_ENVIRONMENT` in your main `index.php`. It seems to me that you could also use this global to define the `$craftPath`.
  
  ```
  switch (CRAFT_ENVIRONMENT) {
      case "dev":
          $craftPath = '../craft';
          break;
      case "stage":
          $craftPath = '../../craft';
          break;
      default:
          // default "production"
          $craftPath = '../../craft';
  }
  
  ```
  
  I generally use the above method (without the new switch part) in combination with [this configuration method](https://craftcms.stackexchange.com/questions/4728/how-to-set-up-siteurl-to-work-with-both-http-and-https/4734?s=1%7C0.1884#4734) in my `general.php` config file.
  
  
  ---
  
  