]> BookStack Code Mirror - bookstack/blob - app/Config/database.php
Upgraded app to Laravel 5.7
[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
15     $redisDefaults = ['host' => '127.0.0.1', 'port' => '6379', 'database' => '0', 'password' => null];
16     $redisServers = explode(',', trim(env('REDIS_SERVERS', '127.0.0.1:6379:0'), ','));
17     $redisConfig = ['client' => 'predis'];
18     $cluster = count($redisServers) > 1;
19
20     if ($cluster) {
21         $redisConfig['clusters'] = ['default' => []];
22     }
23
24     foreach ($redisServers as $index => $redisServer) {
25         $redisServerDetails = explode(':', $redisServer);
26
27         $serverConfig = [];
28         $configIndex = 0;
29         foreach ($redisDefaults as $configKey => $configDefault) {
30             $serverConfig[$configKey] = ($redisServerDetails[$configIndex] ?? $configDefault);
31             $configIndex++;
32         }
33
34         if ($cluster) {
35             $redisConfig['clusters']['default'][] = $serverConfig;
36         } else {
37             $redisConfig['default'] = $serverConfig;
38         }
39     }
40 }
41
42 // MYSQL
43 // Split out port from host if set
44 $mysql_host = env('DB_HOST', 'localhost');
45 $mysql_host_exploded = explode(':', $mysql_host);
46 $mysql_port = env('DB_PORT', 3306);
47 if (count($mysql_host_exploded) > 1) {
48     $mysql_host = $mysql_host_exploded[0];
49     $mysql_port = intval($mysql_host_exploded[1]);
50 }
51
52 return [
53
54     // Default database connection name.
55     // Options: mysql, mysql_testing
56     'default' => env('DB_CONNECTION', 'mysql'),
57
58     // Available database connections
59     // Many of those shown here are unsupported by BookStack.
60     'connections' => [
61
62         'sqlite' => [
63             'driver'   => 'sqlite',
64             'database' => storage_path('database.sqlite'),
65             'prefix'   => '',
66         ],
67
68         'mysql' => [
69             'driver'    => 'mysql',
70             'host'      => $mysql_host,
71             'database'  => env('DB_DATABASE', 'forge'),
72             'username'  => env('DB_USERNAME', 'forge'),
73             'password'  => env('DB_PASSWORD', ''),
74             'unix_socket' => env('DB_SOCKET', ''),
75             'port'      => $mysql_port,
76             'charset'   => 'utf8mb4',
77             'collation' => 'utf8mb4_unicode_ci',
78             'prefix'    => '',
79             'prefix_indexes' => true,
80             'strict'    => false,
81             'engine' => null,
82         ],
83
84         'mysql_testing' => [
85             'driver'    => 'mysql',
86             'host'      => '127.0.0.1',
87             'database'  => 'bookstack-test',
88             'username'  => env('MYSQL_USER', 'bookstack-test'),
89             'password'  => env('MYSQL_PASSWORD', 'bookstack-test'),
90             'charset'   => 'utf8mb4',
91             'collation' => 'utf8mb4_unicode_ci',
92             'prefix'    => '',
93             'prefix_indexes' => true,
94             'strict'    => false,
95         ],
96
97         'pgsql' => [
98             'driver'   => 'pgsql',
99             'host'     => env('DB_HOST', 'localhost'),
100             'database' => env('DB_DATABASE', 'forge'),
101             'username' => env('DB_USERNAME', 'forge'),
102             'password' => env('DB_PASSWORD', ''),
103             'charset'  => 'utf8',
104             'prefix'   => '',
105             'schema'   => 'public',
106         ],
107
108         'sqlsrv' => [
109             'driver'   => 'sqlsrv',
110             'host'     => env('DB_HOST', 'localhost'),
111             'database' => env('DB_DATABASE', 'forge'),
112             'username' => env('DB_USERNAME', 'forge'),
113             'password' => env('DB_PASSWORD', ''),
114             'charset'  => 'utf8',
115             'prefix'   => '',
116         ],
117
118     ],
119
120     // Migration Repository Table
121     // This table keeps track of all the migrations that have already run for
122     // your application. Using this information, we can determine which of
123     // the migrations on disk haven't actually been run in the database.
124     'migrations' => 'migrations',
125
126     // Redis configuration to use if set
127     'redis' => env('REDIS_SERVERS', false) ? $redisConfig : [],
128
129 ];