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 $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]);
53 // Default database connection name.
54 // Options: mysql, mysql_testing
55 'default' => env('DB_CONNECTION', 'mysql'),
57 // Available database connections
58 // Many of those shown here are unsupported by BookStack.
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 // Prefixes are only semi-supported and may be unstable
73 // since they are not tested as part of our automated test suite.
74 // If used, the prefix should not be changed otherwise you will likely receive errors.
75 'prefix' => env('DB_TABLE_PREFIX', ''),
76 'prefix_indexes' => true,
79 'options' => extension_loaded('pdo_mysql') ? array_filter([
80 PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
86 'url' => env('TEST_DATABASE_URL'),
87 'host' => '127.0.0.1',
88 'database' => 'bookstack-test',
89 'username' => env('MYSQL_USER', 'bookstack-test'),
90 'password' => env('MYSQL_PASSWORD', 'bookstack-test'),
91 'port' => $mysql_port,
92 'charset' => 'utf8mb4',
93 'collation' => 'utf8mb4_unicode_ci',
95 'prefix_indexes' => true,
101 // Migration Repository Table
102 // This table keeps track of all the migrations that have already run for
103 // your application. Using this information, we can determine which of
104 // the migrations on disk haven't actually been run in the database.
105 'migrations' => 'migrations',
107 // Redis configuration to use if set
108 'redis' => $redisConfig ?? [],