]> BookStack Code Mirror - bookstack/blob - app/Config/database.php
Add git to the apt-get install packages.
[bookstack] / app / Config / database.php
1 <?php
2
3 /**
4  * Database configuration options.
5  *
6  * Changes to these config files are not supported by BookStack and may break upon updates.
7  * Configuration should be altered via the `.env` file or environment variables.
8  * Do not edit this file unless you're happy to maintain any changes yourself.
9  */
10
11 // REDIS
12 // Split out configuration into an array
13 if (env('REDIS_SERVERS', false)) {
14     $redisDefaults = ['host' => '127.0.0.1', 'port' => '6379', 'database' => '0', 'password' => null];
15     $redisServers = explode(',', trim(env('REDIS_SERVERS', '127.0.0.1:6379:0'), ','));
16     $redisConfig = ['client' => 'predis'];
17     $cluster = count($redisServers) > 1;
18
19     if ($cluster) {
20         $redisConfig['clusters'] = ['default' => []];
21     }
22
23     foreach ($redisServers as $index => $redisServer) {
24         $redisServerDetails = explode(':', $redisServer);
25
26         $serverConfig = [];
27         $configIndex = 0;
28         foreach ($redisDefaults as $configKey => $configDefault) {
29             $serverConfig[$configKey] = ($redisServerDetails[$configIndex] ?? $configDefault);
30             $configIndex++;
31         }
32
33         if ($cluster) {
34             $redisConfig['clusters']['default'][] = $serverConfig;
35         } else {
36             $redisConfig['default'] = $serverConfig;
37         }
38     }
39 }
40
41 // MYSQL
42 // Split out port from host if set
43 $mysql_host = env('DB_HOST', 'localhost');
44 $mysql_host_exploded = explode(':', $mysql_host);
45 $mysql_port = env('DB_PORT', 3306);
46 if (count($mysql_host_exploded) > 1) {
47     $mysql_host = $mysql_host_exploded[0];
48     $mysql_port = intval($mysql_host_exploded[1]);
49 }
50
51 return [
52
53     // Default database connection name.
54     // Options: mysql, mysql_testing
55     'default' => env('DB_CONNECTION', 'mysql'),
56
57     // Available database connections
58     // Many of those shown here are unsupported by BookStack.
59     'connections' => [
60
61         'mysql' => [
62             'driver'    => 'mysql',
63             'url' => env('DATABASE_URL'),
64             'host'      => $mysql_host,
65             'database'  => env('DB_DATABASE', 'forge'),
66             'username'  => env('DB_USERNAME', 'forge'),
67             'password'  => env('DB_PASSWORD', ''),
68             'unix_socket' => env('DB_SOCKET', ''),
69             'port'      => $mysql_port,
70             'charset'   => 'utf8mb4',
71             'collation' => 'utf8mb4_unicode_ci',
72             'prefix'    => '',
73             'prefix_indexes' => true,
74             'strict'    => false,
75             'engine' => null,
76             'options' => extension_loaded('pdo_mysql') ? array_filter([
77                 PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
78             ]) : [],
79         ],
80
81         'mysql_testing' => [
82             'driver'    => 'mysql',
83             'url' => env('TEST_DATABASE_URL'),
84             'host'      => '127.0.0.1',
85             'database'  => 'bookstack-test',
86             'username'  => env('MYSQL_USER', 'bookstack-test'),
87             'password'  => env('MYSQL_PASSWORD', 'bookstack-test'),
88             'charset'   => 'utf8mb4',
89             'collation' => 'utf8mb4_unicode_ci',
90             'prefix'    => '',
91             'prefix_indexes' => true,
92             'strict'    => false,
93         ],
94
95     ],
96
97     // Migration Repository Table
98     // This table keeps track of all the migrations that have already run for
99     // your application. Using this information, we can determine which of
100     // the migrations on disk haven't actually been run in the database.
101     'migrations' => 'migrations',
102
103     // Redis configuration to use if set
104     'redis' => env('REDIS_SERVERS', false) ? $redisConfig : [],
105
106 ];
Morty Proxy This is a proxified and sanitized view of the page, visit original site.