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)) {
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;
21 $redisConfig['clusters'] = ['default' => []];
24 foreach ($redisServers as $index => $redisServer) {
25 $redisServerDetails = explode(':', $redisServer);
29 foreach ($redisDefaults as $configKey => $configDefault) {
30 $serverConfig[$configKey] = ($redisServerDetails[$configIndex] ?? $configDefault);
35 $redisConfig['clusters']['default'][] = $serverConfig;
37 $redisConfig['default'] = $serverConfig;
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]);
54 // Default database connection name.
55 // Options: mysql, mysql_testing
56 'default' => env('DB_CONNECTION', 'mysql'),
58 // Available database connections
59 // Many of those shown here are unsupported by BookStack.
64 'url' => env('DATABASE_URL'),
65 'host' => $mysql_host,
66 'database' => env('DB_DATABASE', 'forge'),
67 'username' => env('DB_USERNAME', 'forge'),
68 'password' => env('DB_PASSWORD', ''),
69 'unix_socket' => env('DB_SOCKET', ''),
70 'port' => $mysql_port,
71 'charset' => 'utf8mb4',
72 'collation' => 'utf8mb4_unicode_ci',
74 'prefix_indexes' => true,
77 'options' => extension_loaded('pdo_mysql') ? array_filter([
78 PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
84 'url' => env('TEST_DATABASE_URL'),
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' => 'utf8mb4',
90 'collation' => 'utf8mb4_unicode_ci',
92 'prefix_indexes' => true,
98 // Migration Repository Table
99 // This table keeps track of all the migrations that have already run for
100 // your application. Using this information, we can determine which of
101 // the migrations on disk haven't actually been run in the database.
102 'migrations' => 'migrations',
104 // Redis configuration to use if set
105 'redis' => env('REDIS_SERVERS', false) ? $redisConfig : [],