1<?php
2
3/**
4 * All the automated casting in model requires mysqlnd.
5 * This function check is inspired by
6 * https://stackoverflow.com/a/22499259 .
7 */
8
9if (!function_exists('mysqli_get_client_stats')) {
10 exit('Required mysqlnd driver is missing.');
11}
12
13$mysqlDefaults = [
14 'driver' => 'mysql',
15 'host' => env('DB_HOST', 'localhost'),
16 'username' => env('DB_USERNAME', 'osuweb'),
17 'password' => env('DB_PASSWORD', ''),
18 'port' => env('DB_PORT', '3306'),
19 'charset' => 'utf8mb4',
20 'collation' => 'utf8mb4_0900_ai_ci',
21 'prefix' => '',
22 /*
23 * This should match latest sane default[1].
24 * It's set manually here because ProxySQL only supports protocol version 5.x[2] and
25 * Laravel sends obsolete SQL mode[3] if set to strict mode and detect older server version.
26 * [1] https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html
27 * [2] https://github.com/sysown/proxysql/issues/2021
28 * [3] https://github.com/laravel/framework/blob/36fdbd4c6a35d689384eebd4c33477a6b444d883/src/Illuminate/Database/Connectors/MySqlConnector.php#L183
29 */
30 'modes' => [
31 'ONLY_FULL_GROUP_BY',
32 'STRICT_TRANS_TABLES',
33 'NO_ZERO_IN_DATE',
34 'NO_ZERO_DATE',
35 'ERROR_FOR_DIVISION_BY_ZERO',
36 'NO_ENGINE_SUBSTITUTION',
37 ],
38 'options' => [
39 PDO::ATTR_PERSISTENT => true,
40 PDO::MYSQL_ATTR_INIT_COMMAND => "SET time_zone = '+00:00'",
41 ],
42];
43
44$redisDefault = [
45 'host' => presence(env('REDIS_HOST')) ?? '127.0.0.1',
46 'port' => get_int(env('REDIS_PORT')) ?? 6379,
47 'database' => get_int(env('REDIS_DB')) ?? 0,
48 'password' => presence(env('REDIS_PASSWORD')),
49 'persistent' => true,
50];
51$redisCachePrefix = 'osu-next:';
52
53return [
54
55 /*
56 |--------------------------------------------------------------------------
57 | Default Database Connection Name
58 |--------------------------------------------------------------------------
59 |
60 | Here you may specify which of the database connections below you wish
61 | to use as your default connection for all database work. Of course
62 | you may use many connections at once using the Database library.
63 |
64 */
65
66 'default' => 'mysql',
67
68 /*
69 |--------------------------------------------------------------------------
70 | Database Connections
71 |--------------------------------------------------------------------------
72 |
73 | Here are each of the database connections setup for your application.
74 | Of course, examples of configuring each database platform that is
75 | supported by Laravel is shown below to make development simple.
76 |
77 |
78 | All database work in Laravel is done through the PHP PDO facilities
79 | so make sure you have the driver for your particular database of
80 | choice installed on your machine before you begin development.
81 |
82 */
83
84 'connections' => [
85 'mysql' => array_merge($mysqlDefaults, [
86 'database' => env('DB_DATABASE', 'osu'),
87 ]),
88
89 'mysql-mp' => array_merge($mysqlDefaults, [
90 'database' => env('DB_DATABASE_MP', 'osu_mp'),
91 ]),
92
93 'mysql-charts' => array_merge($mysqlDefaults, [
94 'database' => env('DB_DATABASE_CHARTS', 'osu_charts'),
95 ]),
96
97 'mysql-chat' => array_merge($mysqlDefaults, [
98 'database' => env('DB_DATABASE_CHAT', 'osu_chat'),
99 ]),
100
101 'mysql-store' => array_merge($mysqlDefaults, [
102 'database' => env('DB_DATABASE_STORE', 'osu_store'),
103 ]),
104
105 'mysql-updates' => array_merge($mysqlDefaults, [
106 'database' => env('DB_DATABASE_UPDATES', 'osu_updates'),
107 ]),
108 ],
109
110 /*
111 |--------------------------------------------------------------------------
112 | Migration Repository Table
113 |--------------------------------------------------------------------------
114 |
115 | This table keeps track of all the migrations that have already run for
116 | your application. Using this information, we can determine which of
117 | the migrations on disk haven't actually been run in the database.
118 |
119 */
120
121 'migrations' => 'migrations',
122
123 /*
124 |--------------------------------------------------------------------------
125 | Redis Databases
126 |--------------------------------------------------------------------------
127 |
128 | Redis is an open source, fast, and advanced key-value store that also
129 | provides a richer set of commands than a typical key-value systems
130 | such as APC or Memcached. Laravel makes it easy to dig right in.
131 |
132 */
133
134 'redis' => [
135
136 'client' => 'phpredis',
137
138 'cluster' => false,
139
140 'cache' => [
141 'host' => presence(env('CACHE_REDIS_HOST')) ?? presence(env('REDIS_HOST')) ?? '127.0.0.1',
142 'port' => get_int(env('CACHE_REDIS_PORT')) ?? get_int(env('REDIS_PORT')) ?? 6379,
143 'database' => get_int(env('CACHE_REDIS_DB')) ?? 0,
144 'password' => presence(env('CACHE_REDIS_PASSWORD')) ?? presence(env('REDIS_PASSWORD')),
145 'persistent' => true,
146 'prefix' => $redisCachePrefix,
147 ],
148
149 'default' => $redisDefault,
150
151 'notification' => [
152 'host' => presence(env('NOTIFICATION_REDIS_HOST')) ?? '127.0.0.1',
153 'port' => get_int(env('NOTIFICATION_REDIS_PORT')) ?? 6379,
154 'database' => get_int(env('NOTIFICATION_REDIS_DB')) ?? 0,
155 'password' => presence(env('NOTIFICATION_REDIS_PASSWORD')),
156 'persistent' => true,
157 ],
158
159 'session' => [
160 ...$redisDefault,
161 'prefix' => $redisCachePrefix,
162 ],
163 ],
164
165];