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.


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.

    case "dev":
        $craftPath = '../craft';
    case "stage":
        $craftPath = '../../craft';
        // 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.