Skip to content

Instantly share code, notes, and snippets.

@doostinharrell
Last active March 25, 2019 20:22
Show Gist options
  • Save doostinharrell/1f4a9551a7ceaa25b2b2785b025bde60 to your computer and use it in GitHub Desktop.
Save doostinharrell/1f4a9551a7ceaa25b2b2785b025bde60 to your computer and use it in GitHub Desktop.
Drupal 6 settings.php
<?php
// Database configuration.
$db_host = 'database';
$db_username = 'drupal6';
$db_password = 'drupal6';
$db_database = 'drupal6';
$db_url = 'mysql://' . $db_username . ':' . $db_password . '@' . $db_host . '/' . $db_database;
// Update settings.php for local lando dev.
if (!empty($_SERVER['DOCKER_DEV'])) {
preg_match('([\w-]+\.[\w]+)', getcwd(), $project_root);
preg_match('(^[\w-]+)', $project_root[0], $dir_root);
$container = str_replace('-', '', $dir_root[0]);
$cmd = "/usr/local/bin/docker port " . $container . "_database_1 3306 | grep -Eo '\d+$'";
$port = trim(shell_exec($cmd));
// Set $base_url variable.
if (!empty($project_root)) {
GLOBAL $base_url;
$base_url = 'http://' . $dir_root[0] . '.lndo.site';
}
// Database configuration.
$db_host = '0.0.0.0';
$db_username = 'drupal6';
$db_password = 'drupal6';
$db_database = 'drupal6';
$db_url = 'mysql://' . $db_username . ':' . $db_password . '@' . $db_host . ':' . $port . '/' . $db_database;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment