Skip to content

Instantly share code, notes, and snippets.

@danpoltawski
Created August 3, 2011 20:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danpoltawski/1123720 to your computer and use it in GitHub Desktop.
Save danpoltawski/1123720 to your computer and use it in GitHub Desktop.
Moodle config.php files
<?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
/**************************************************
* Work out a branch prefix based on the remote tracking branch
**************************************************/
$remotebranch = trim(`cd /home/danp/git/moodle; /usr/bin/git branch -vv | grep '^\*' | awk '{print $4}' | perl -ne 'm/\/([^:^\]]*)/; print $1'`);
// default...
$branchprefix = 'other';
if ($remotebranch == 'master') {
// easy to remember prefix
$branchprefix = 'mdl';
}elseif (preg_match('/MOODLE_(\d+)_STABLE/', $remotebranch, $matches)) {
// MOODLE_21_STABLE becomes m21_
$branchprefix = 'm'.$matches[1];
}elseif (!empty($remotebranch)) {
// make a new prefix for crazy remote
$branchprefix = substr(preg_replace('/\W*/', '', $remotebranch), 0, 7);
}
/**************************************************
* I'm in dans home directory
**************************************************/
$CFG->wwwroot = 'http://localhost/moodle';
$CFG->dirroot = '/home/danp/git/moodle';
/**************************************************
* Switch between DB's..
**************************************************/
$CFG->dbtype = 'mysqli';
//$CFG->dbtype = 'postgres7';
// Setup DB prefix..
$CFG->prefix = $branchprefix.'_';
// setup cookie..
$CFG->sessioncookie = $branchprefix.$CFG->dbtype;
// Setup data directory
$CFG->dataroot = '/var/lib/moodle/'.$branchprefix;
// make data subdirector if it doesn't exist..
if (!is_dir($CFG->dataroot)) {
mkdir($CFG->dataroot);
}
// debugging settings...
define('MDL_PERF', true);
define('MDL_PERFDB', true);
define('MDL_PERFTOFOOT', true);
$CFG->debug = 38911; // DEBUG_DEVELOPER
$CFG->debugdisplay = 1; // I notice notices better
$CFG->noemailever = 1; // dont spam real users
$CFG->loginhttps = 0; // for testing https sites dbs on my machine
$CFG->passwordpolicy = 0; // because making complex test passwords is hard!
// database settings
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'moodle';
$CFG->dbpass = 'dan-has-crap-passwords';
$CFG->unittestprefix = 'tst_';
$CFG->dboptions = array (
'dbpersist' => 0,
//'logall' => true,
'dbsocket' => 0,
);
$CFG->admin = 'admin';
$CFG->directorypermissions = 0777;
require_once($CFG->dirroot.'/lib/setup.php');
// There is no php closing tag in this file,
// // it is intentional because it prevents trailing whitespace problems!
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment