]> BookStack Code Mirror - bookstack/blob - config/database.php
Hide permissions table unless custom permissions are enabled
[bookstack] / 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 = [];
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             'strict'    => false,
80             'engine' => null,
81         ],
82
83         'mysql_testing' => [
84             'driver'    => 'mysql',
85             'host'      => '127.0.0.1',
86             'database'  => 'bookstack-test',
87             'username'  => env('MYSQL_USER', 'bookstack-test'),
88             'password'  => env('MYSQL_PASSWORD', 'bookstack-test'),
89             'charset'   => 'utf8',
90             'collation' => 'utf8_unicode_ci',
91             'prefix'    => '',
92             'strict'    => false,
93         ],
94
95         'pgsql' => [
96             'driver'   => 'pgsql',
97             'host'     => env('DB_HOST', 'localhost'),
98             'database' => env('DB_DATABASE', 'forge'),
99             'username' => env('DB_USERNAME', 'forge'),
100             'password' => env('DB_PASSWORD', ''),
101             'charset'  => 'utf8',
102             'prefix'   => '',
103             'schema'   => 'public',
104         ],
105
106         'sqlsrv' => [
107             'driver'   => 'sqlsrv',
108             'host'     => env('DB_HOST', 'localhost'),
109             'database' => env('DB_DATABASE', 'forge'),
110             'username' => env('DB_USERNAME', 'forge'),
111             'password' => env('DB_PASSWORD', ''),
112             'charset'  => 'utf8',
113             'prefix'   => '',
114         ],
115
116     ],
117
118     // Migration Repository Table
119     // This table keeps track of all the migrations that have already run for
120     // your application. Using this information, we can determine which of
121     // the migrations on disk haven't actually been run in the database.
122     'migrations' => 'migrations',
123
124     // Redis configuration to use if set
125     'redis' => env('REDIS_SERVERS', false) ? $redisConfig : [],
126
127 ];
Morty Proxy This is a proxified and sanitized view of the page, visit original site.