2

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.

Matt Stein
  • 4,006
  • 3
  • 26
  • 57
nerdology
  • 23
  • 2

1 Answers1

2

There is a really nice multi-environment configuration 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 in my general.php config file.

Douglas McDonald
  • 13,457
  • 24
  • 57