Created
March 4, 2022 20:45
-
-
Save herbdool/baec130982e3995b5577008f1a63ebd9 to your computer and use it in GitHub Desktop.
Pantheon settings for CiviCRM
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 | |
/** | |
* CiviCRM Local configuration file. | |
*/ | |
/** | |
* 1. After installing CiviCRM place this snippet in civicrm.settings.php, | |
* just below | |
* "global $civicrm_root, $civicrm_setting, $civicrm_paths;" | |
* | |
* if (file_exists(__DIR__ . '/civicrm.settings.local.php')) { | |
* include __DIR__ . '/civicrm.settings.local.php'; | |
* } | |
* | |
* 2. Copy this file into the same directory and rename it to | |
* civicrm.settings.local.php | |
* | |
* 3. Copy and secret keys generated from civicrm.settings.php | |
* and place them into this file. | |
*/ | |
/** | |
* Pantheon settings: | |
* Populate needed variables based on the Pantheon environment. | |
*/ | |
if (!empty($_ENV['PANTHEON_SITE'])) { | |
$pantheon_home = $_ENV['HOME'] . ($_ENV['HOME'] !== '/' ? '/' : ''); | |
// Database Username and Password | |
$pantheon_db = 'mysql://' . $_ENV['DB_USER'] . ':' . $_ENV['DB_PASSWORD'] . '@'; | |
// Host | |
$pantheon_db .= $_ENV['DB_HOST'] . ':' . $_ENV['DB_PORT']; | |
// Database | |
$pantheon_db .= '/' . $_ENV['DB_NAME'] . '?new_link=true'; | |
} | |
/** | |
* CMS | |
*/ | |
define('CIVICRM_UF', 'Drupal8'); | |
/** | |
* Databases | |
*/ | |
if (isset($_ENV['PANTHEON_SITE'])) { | |
define('CIVICRM_UF_DSN', $pantheon_db); | |
} else { | |
define('CIVICRM_UF_DSN', 'mysql://cms_db_username:cms_db_password@db_server/cms_database?new_link=true%%CMSdbSSL%%'); | |
} | |
if (isset($_ENV['PANTHEON_SITE'])) { | |
define('CIVICRM_DSN', $pantheon_db); | |
} else { | |
define('CIVICRM_DSN', 'mysql://crm_db_username:crm_db_password@db_server/crm_database?new_link=true%%dbSSL%%'); | |
} | |
/** | |
* Secret Keys | |
* | |
* @see https://docs.civicrm.org/sysadmin/en/latest/setup/secret-keys/ | |
* | |
* Either copy these from the main settings file or generate new keys by following | |
* the guide linked above. | |
*/ | |
define('CIVICRM_SITE_KEY', 'ADD_RANDOM_KEY'); | |
define('CIVICRM_CRED_KEYS', 'GENERATE_RANDOM_KEY'); | |
define('CIVICRM_SIGN_KEYS', 'GENERATE_RANDOM_KEY'); | |
/** | |
* File paths and URLs | |
*/ | |
// CiviCRM root | |
if (isset($_ENV['PANTHEON_SITE'])) { | |
$civicrm_root = $pantheon_home . 'code/vendor/civicrm/civicrm-core/'; | |
} else { | |
$civicrm_root = '/app/vendor/civicrm/civicrm-core/'; | |
} | |
// Templates | |
if (isset($_ENV['PANTHEON_SITE'])) { | |
define('CIVICRM_TEMPLATE_COMPILEDIR', $pantheon_home . 'tmp/civicrm/templates_c/'); | |
} else { | |
define('CIVICRM_TEMPLATE_COMPILEDIR', '/app/private/civicrm/templates_c'); | |
} | |
/** | |
* URL settings | |
*/ | |
// Detect if is Pantheon server | |
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) { | |
define('CIVICRM_UF_BASEURL', $_SERVER['HTTP_X_FORWARDED_PROTO'] . '://' . $_SERVER['HTTP_X_FORWARDED_HOST'] . '/'); | |
} else { | |
define('CIVICRM_UF_BASEURL', $_SERVER['HTTP_X_PROTO'] . $_SERVER['HTTP_HOST'] . '/'); | |
} | |
/** | |
* Provide a default public and private CiviCRM file path on Pantheon. | |
* | |
* Set [civicrm.files] and [civicrm.private] since Pantheon provides a files/private | |
* directory instead of using Apache to set permissions on directories. | |
*/ | |
if (isset($_ENV['PANTHEON_SITE'])) { | |
$civicrm_paths['civicrm.files']['path'] = $pantheon_home . 'files/civicrm'; | |
$civicrm_paths['civicrm.files']['url'] = CIVICRM_UF_BASEURL . 'sites/default/files/civicrm/'; | |
$civicrm_paths['civicrm.private']['path'] = $pantheon_home . 'files/private/civicrm'; | |
} else { | |
$civicrm_paths['civicrm.files']['path'] = '/app/httpdocs/sites/default/files/civicrm'; | |
$civicrm_paths['civicrm.files']['url'] = CIVICRM_UF_BASEURL . 'sites/default/files/civicrm/'; | |
$civicrm_paths['civicrm.private']['path'] = '/app/private/civicrm'; | |
} | |
/** | |
* Override File directories and URLs. | |
* | |
* @see https://docs.civicrm.org/sysadmin/en/latest/customize/settings/ | |
*/ | |
/** | |
* Override File directories and URLs. | |
*/ | |
// Override the Temporary Files directory. | |
$civicrm_setting['domain']['uploadDir'] = '[civicrm.private]/upload/'; | |
// Override the Custom Files Upload directory. | |
$civicrm_setting['domain']['customFileUploadDir'] = '[civicrm.private]/custom/'; | |
// Override the Images directory. | |
$civicrm_setting['domain']['imageUploadDir'] = '[civicrm.files]/persist/contribute/'; | |
// Override the Image Upload URL (System Settings > Resource URLs) | |
$civicrm_setting['domain']['imageUploadURL'] = '[civicrm.files]/persist/contribute/'; | |
// Override the Resource URL | |
$civicrm_setting['domain']['userFrameworkResourceURL'] = CIVICRM_UF_BASEURL . 'libraries/civicrm/core'; | |
/** | |
* Custom Template and PHP files. | |
*/ | |
// Override the Custom Templates directory | |
$civicrm_setting['domain']['customTemplateDir'] = '[cms.root]/sites/all/civicrm_custom/custom_templates/'; | |
// Override the Custom PHP directory | |
$civicrm_setting['domain']['customPHPPathDir'] = '[cms.root]/sites/all/civicrm_custom/custom_php/'; | |
/** | |
* Extensions | |
*/ | |
// Override the Extensions directory. | |
$civicrm_setting['domain']['extensionsDir'] = '[cms.root]/sites/all/civicrm_custom/extensions/'; | |
// Override the Extensions Resource URL | |
$civicrm_setting['domain']['extensionsURL'] = '[cms.root]/sites/all/civicrm_custom/extensions'; | |
// Disable automatic download / installation of Extensions on testing/live | |
if (isset($_ENV['PANTHEON_ENVIRONMENT']) && (!in_array($_ENV['PANTHEON_ENVIRONMENT'], array('live', 'test')))) { | |
$civicrm_setting['domain']['ext_repo_url'] = false; | |
} else { | |
$civicrm_setting['domain']['ext_repo_url'] = true; | |
} | |
// Override the Custom CiviCRM CSS URL | |
// $civicrm_setting['domain']['customCSSURL'] = '[cms.root]/example-css-url' ; | |
// Disable display of Community Messages on home dashboard | |
// $civicrm_setting['domain']['communityMessagesUrl'] = false; | |
// Disable automatic download / installation of extensions | |
// $civicrm_setting['domain']['ext_repo_url'] = false; | |
// set triggers to be managed offline per CRM-18212 | |
// $civicrm_setting['domain']['logging_no_trigger_permission'] = 1; | |
// Override the CMS root path defined by cmsRootPath. | |
// define('CIVICRM_CMSDIR', '/path/to/install/root/'); | |
// Opt-out of announcements by the CiviCRM core team for releases, paid services, events, etc. | |
// $civicrm_setting['domain']['communityMessagesUrl'] = 'https://alert.civicrm.org/alert?prot=1&ver={ver}&uf={uf}&sid={sid}&lang={lang}&co={co}&optout=offers,asks'; | |
/** | |
* SMARTY Compile Check: | |
*/ | |
define('CIVICRM_TEMPLATE_COMPILE_CHECK', FALSE); | |
/** | |
* Environment settings | |
*/ | |
// Pantheon: if it's not the live site then send all emails to a log file | |
if (isset($_ENV['PANTHEON_SITE']) && $_ENV['PANTHEON_ENVIRONMENT'] != 'live') { | |
define('CIVICRM_MAIL_LOG', '[civicrm.private]/ConfigAndLog/mail.log'); | |
} | |
// if (!isset($_ENV['PANTHEON_SITE']) && !defined('CIVICRM_MAIL_LOG')) { | |
// define( 'CIVICRM_MAIL_LOG', '/full/path/to/files/civicrm/ConfigAndLog/mail.log'); | |
// } | |
/** | |
* This setting will only work if CIVICRM_MAIL_LOG is defined. Mail will be logged and then sent. | |
*/ | |
//if (!defined('CIVICRM_MAIL_LOG_AND_SEND')) { | |
// define( 'CIVICRM_MAIL_LOG_AND_SEND', 1); | |
//} | |
/** | |
* Define CiviCRM environment | |
* | |
* Options: 'Production', 'Staging', 'Development'. | |
*/ | |
$civicrm_setting['domain']['environment'] = 'Development'; | |
if ($_ENV['PANTHEON_ENVIRONMENT']) { | |
if ($_ENV['PANTHEON_ENVIRONMENT'] == 'live') { | |
$civicrm_setting['domain']['environment'] = 'Production'; | |
} elseif ($_ENV['PANTHEON_ENVIRONMENT'] == 'test') { | |
$civicrm_setting['domain']['environment'] = 'Staging'; | |
} | |
} | |
/** | |
* Cache server | |
*/ | |
// If using Redis on Pantheon | |
if (!empty($_ENV['PANTHEON_SITE'] && !empty($_ENV['CACHE_HOST']))) { | |
define('CIVICRM_DB_CACHE_CLASS', 'Redis'); | |
define('CIVICRM_DB_CACHE_HOST', $_ENV['CACHE_HOST']); | |
define('CIVICRM_DB_CACHE_PORT', $_ENV['CACHE_PORT']); | |
define('CIVICRM_DB_CACHE_PASSWORD', $_ENV['CACHE_PASSWORD']); | |
define('CIVICRM_DB_CACHE_TIMEOUT', 3600); | |
define('CIVICRM_DB_CACHE_PREFIX', 'pantheon-redis-civicrm:'); | |
} else { | |
// Adjust for local dev settings | |
define('CIVICRM_DB_CACHE_CLASS', 'ArrayCache'); | |
define('CIVICRM_DB_CACHE_HOST', 'localhost'); | |
if (CIVICRM_DB_CACHE_CLASS === 'Redis') { | |
define('CIVICRM_DB_CACHE_PORT', 6379); | |
} else { | |
define('CIVICRM_DB_CACHE_PORT', 11211); | |
} | |
define('CIVICRM_DB_CACHE_PASSWORD', ''); | |
define('CIVICRM_DB_CACHE_TIMEOUT', 3600); | |
define('CIVICRM_DB_CACHE_PREFIX', ''); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment