SproutCMS

This is the code documentation for the SproutCMS project

source of /modules/Welcome/config_tmpl/database.php

Database connection settings.

Each array is a separate group, which can be connected to independently.

The standard connection used by Pdb is the 'default' group, but
the method Pdb::connect can be used to connect to other groups

Group Options:
 connection      Array of connection specific parameters:
      type       Only supported value is 'mysql'
      host       Hostname
      user       Username
      pass       Password
      port       If non-empty, specifies a non-standard port
      database   Database name
 character_set   Database character set
  1. <?php
  2. /*
  3.  * Copyright (C) 2017 Karmabunny Pty Ltd.
  4.  *
  5.  * This file is a part of SproutCMS.
  6.  *
  7.  * SproutCMS is free software: you can redistribute it and/or modify it under the terms
  8.  * of the GNU General Public License as published by the Free Software Foundation, either
  9.  * version 2 of the License, or (at your option) any later version.
  10.  *
  11.  * For more information, visit <http://getsproutcms.com>.
  12.  */
  13.  
  14. /**
  15. * Database connection settings.
  16. *
  17. * Each array is a separate group, which can be connected to independently.
  18. *
  19. * The standard connection used by {@see Pdb} is the 'default' group, but
  20. * the method {@see Pdb::connect} can be used to connect to other groups
  21. *
  22. * Group Options:
  23. * connection Array of connection specific parameters:
  24. * type Only supported value is 'mysql'
  25. * host Hostname
  26. * user Username
  27. * pass Password
  28. * port If non-empty, specifies a non-standard port
  29. * database Database name
  30. * character_set Database character set
  31. **/
  32.  
  33.  
  34. if (IN_PRODUCTION) {
  35. // Live server config
  36. $config['default'] = [
  37. 'connection' => [
  38. 'type' => 'mysql',
  39. 'user' => '{{PROD-USER}}',
  40. 'database' => '{{PROD-DATABASE}}',
  41. 'host' => '{{PROD-HOST}}',
  42. 'port' => FALSE,
  43. ],
  44. 'character_set' => 'utf8',
  45. ];
  46.  
  47. // Rather than entering the PRODUCTION database password direct in
  48. // the config (which would then be saved in repo history and could
  49. // accidently become public), it's much better to include this in
  50. // a separate file, preferably outside of DOCROOT.
  51. //
  52. // Example file content:
  53. // <?php
  54. // $config['default']['connection']['pass'] = 'abcd1234';
  55. //
  56. // The example path below would be used if the file is a sibling
  57. // of the main public_html directory
  58. //
  59. if (!file_exists(DOCROOT . '../database.config.php')) {
  60. throw new Exception('Missing database password config file');
  61. }
  62.  
  63. require DOCROOT . '../database.config.php';
  64.  
  65. // A unique random key for this site
  66. $config['server_key'] = '{{SERVER-KEY}}';
  67.  
  68. } else {
  69. // Test server config
  70. $config['default'] = [
  71. 'connection' => [
  72. 'type' => 'mysql',
  73. 'user' => '{{TEST-USER}}',
  74. 'pass' => '{{TEST-PASS}}',
  75. 'database' => '{{TEST-DATABASE}}',
  76. 'host' => '{{TEST-HOST}}',
  77. 'port' => FALSE,
  78. ],
  79. 'character_set' => 'utf8',
  80. ];
  81.  
  82. // This key is not secure, so it must not be used in production environments
  83. $config['server_key'] = 'NOT SECURE';
  84. }
  85.