-
-
Save a-am/0faf3663bd71e5393972cc9826f3c6d9 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" => "test@example.com", | |
), | |
"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