1

On my local dev sever, as well as the production server, the craft folder is one level above web root, so $craftPath in index.php is set like so:

$craftPath = '../craft';

On the staging server, the craft folder is two levels above web root, so $craftPath needs to be:

$craftPath = '../../craft';

Can this be accomplished in a single index.php file? Something similar to the multi-environment array in config/general.php and config/db.php perhaps?

3

Should be able to. Use a switch statement to check on the host and then server up the correct environment configuration like so:

public/index.php:

switch (strtolower($_SERVER['SERVER_NAME']))
{
    // Staging
    case 'stage.mydomain.com' :
        define('CRAFT_ENVIRONMENT', 'stage');
        $craftPath = '../../craft';
        break;

    // Local
    default :
        define('CRAFT_ENVIRONMENT', 'local');
        $craftPath = '../craft';
        break;
}

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.