Last active
May 11, 2016 16:09
-
-
Save nfourtythree/9a5601c030a659615590d750c8afb99f to your computer and use it in GitHub Desktop.
Craft Environments Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Database Configuration | |
* | |
* All of your system's database configuration settings go in here. | |
* You can see a list of the default settings in craft/app/etc/config/defaults/db.php | |
*/ | |
return array( | |
"*" => array( | |
"server" => "127.0.0.1", | |
"tablePrefix" => "craft", | |
), | |
"local" => array( | |
"user" => "root", | |
"password" => "", | |
"database" => "craft", | |
), | |
"dev" => array( | |
"user" => "", | |
"password" => "", | |
"database" => "", | |
), | |
"staging" => array( | |
"user" => "", | |
"password" => "", | |
"database" => "", | |
), | |
"production" => array( | |
"user" => "", | |
"password" => "", | |
"database" => "", | |
), | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* General Configuration | |
* | |
* All of your system's general configuration settings go in here. | |
* You can see a list of the default settings in craft/app/etc/config/defaults/general.php | |
*/ | |
return array( | |
"*" => array( | |
"maxUploadFileSize" => 50554432, | |
"omitScriptNameInUrls" => true, | |
"appId" => $_SERVER['SERVER_NAME'], | |
"siteUrl" => $_SERVER['REQUEST_SCHEME'] . "://" . $_SERVER['SERVER_NAME'], | |
"environmentVariables" => array( | |
'basePath' => $_SERVER["DOCUMENT_ROOT"], | |
'baseUrl' => $_SERVER['REQUEST_SCHEME'] . "://" . $_SERVER['SERVER_NAME'], | |
), | |
), | |
"local" => array( | |
"devMode" => true, | |
"testToEmailAddress" => "[email protected]", | |
), | |
"dev" => array( | |
"devMode" => true, | |
), | |
"staging" => array( | |
), | |
"production" => array( | |
), | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Path to your craft/ folder | |
$craftPath = '../craft'; | |
$envs = array( | |
"local" => array( | |
"en_gb" => array("example.craft.dev", "127.0.0.1.xip.io"), | |
), | |
"dev" => array( | |
"en_gb" => array("dev.example.com"), | |
), | |
"staging" => array( | |
"en_gb" => array("staging.example.com"), | |
), | |
"production" => array( | |
"en_gb" => array("example.com"), | |
), | |
); | |
$fallbackEnv = "local"; | |
$fallbackLocale = "en_gb"; | |
$envSet = false; | |
function setEnv($locale, $env) | |
{ | |
define('CRAFT_SITE_URL', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['SERVER_NAME']); | |
define('CRAFT_LOCALE', $locale); | |
define('CRAFT_ENVIRONMENT', $env); | |
} | |
foreach($envs as $env => $locales) | |
{ | |
foreach($locales as $locale => $domains) | |
{ | |
if (in_array($_SERVER['SERVER_NAME'], $domains)) { | |
setEnv($locale, $env); | |
$envSet = true; | |
break; | |
} | |
} | |
} | |
if (!$envSet) { | |
setEnv($fallbackLocale, $fallbackEnv); | |
} | |
// Do not edit below this line | |
$path = rtrim($craftPath, '/').'/app/index.php'; | |
if (!is_file($path)) | |
{ | |
if (function_exists('http_response_code')) | |
{ | |
http_response_code(503); | |
} | |
exit('Could not find your craft/ folder. Please ensure that <strong><code>$craftPath</code></strong> is set correctly in '.__FILE__); | |
} | |
require_once $path; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment