4 * Database configuration options.
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.
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;
20 $redisConfig['clusters'] = ['default' => []];
23 foreach ($redisServers as $index => $redisServer) {
24 $redisServerDetails = explode(':', $redisServer);
28 foreach ($redisDefaults as $configKey => $configDefault) {
29 $serverConfig[$configKey] = ($redisServerDetails[$configIndex] ?? $configDefault);
34 $redisConfig['clusters']['default'][] = $serverConfig;
36 $redisConfig['default'] = $serverConfig;
42 // Split out port from host if set
43 $mysqlHost = env('DB_HOST', 'localhost');
44 $mysqlHostExploded = explode(':', $mysqlHost);
45 $mysqlPort = env('DB_PORT', 3306);
46 $mysqlHostIpv6 = str_starts_with($mysqlHost, '[');
47 if ($mysqlHostIpv6 && str_contains($mysqlHost, ']:')) {
48 $mysqlHost = implode(':', array_slice($mysqlHostExploded, 0, -1));
49 $mysqlPort = intval(end($mysqlHostExploded));
50 } else if (!$mysqlHostIpv6 && count($mysqlHostExploded) > 1) {
51 $mysqlHost = $mysqlHostExploded[0];
52 $mysqlPort = intval($mysqlHostExploded[1]);
57 // Default database connection name.
58 // Options: mysql, mysql_testing
59 'default' => env('DB_CONNECTION', 'mysql'),
61 // Available database connections
62 // Many of those shown here are unsupported by BookStack.
67 'url' => env('DATABASE_URL'),
69 'database' => env('DB_DATABASE', 'forge'),
70 'username' => env('DB_USERNAME', 'forge'),
71 'password' => env('DB_PASSWORD', ''),
72 'unix_socket' => env('DB_SOCKET', ''),
74 'charset' => 'utf8mb4',
75 'collation' => 'utf8mb4_unicode_ci',
76 // Prefixes are only semi-supported and may be unstable
77 // since they are not tested as part of our automated test suite.
78 // If used, the prefix should not be changed otherwise you will likely receive errors.
79 'prefix' => env('DB_TABLE_PREFIX', ''),
80 'prefix_indexes' => true,
83 'options' => extension_loaded('pdo_mysql') ? array_filter([
84 PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
90 'url' => env('TEST_DATABASE_URL'),
91 'host' => '127.0.0.1',
92 'database' => 'bookstack-test',
93 'username' => env('MYSQL_USER', 'bookstack-test'),
94 'password' => env('MYSQL_PASSWORD', 'bookstack-test'),
96 'charset' => 'utf8mb4',
97 'collation' => 'utf8mb4_unicode_ci',
99 'prefix_indexes' => true,
105 // Migration Repository Table
106 // This table keeps track of all the migrations that have already run for
107 // your application. Using this information, we can determine which of
108 // the migrations on disk haven't actually been run in the database.
109 'migrations' => 'migrations',
111 // Redis configuration to use if set
112 'redis' => $redisConfig ?? [],