firefly-iii/config/database.php

102 lines
3.5 KiB
PHP
Raw Normal View History

2015-02-05 21:39:52 -06:00
<?php
2017-10-21 01:40:00 -05:00
/**
* database.php
* Copyright (c) 2017 thegrumpydictator@gmail.com
*
* This file is part of Firefly III.
*
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2017-12-17 07:44:46 -06:00
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
2017-10-21 01:40:00 -05:00
*/
2017-09-14 10:40:02 -05:00
declare(strict_types=1);
2017-08-12 03:27:45 -05:00
2017-11-29 09:23:17 -06:00
$databaseUrl = getenv('DATABASE_URL');
$host = '';
$username = '';
$password = '';
$database = '';
2018-10-21 04:08:54 -05:00
if (!(false === $databaseUrl)) {
2017-11-29 09:26:00 -06:00
$options = parse_url($databaseUrl);
$host = $options['host'];
$username = $options['user'];
$password = $options['pass'];
$database = substr($options['path'], 1);
}
2017-11-29 09:23:17 -06:00
2015-02-05 21:39:52 -06:00
return [
2018-04-26 23:26:37 -05:00
'default' => envNonEmpty('DB_CONNECTION', 'mysql'),
2015-02-07 03:32:15 -06:00
'connections' => [
'sqlite' => [
2016-11-19 08:55:49 -06:00
'driver' => 'sqlite',
2018-04-26 23:26:37 -05:00
'database' => envNonEmpty('DB_DATABASE', storage_path('database/database.sqlite')),
2016-11-19 08:55:49 -06:00
'prefix' => '',
2015-02-07 03:32:15 -06:00
],
2017-09-09 15:32:11 -05:00
'mysql' => [
'driver' => 'mysql',
2018-04-26 23:26:37 -05:00
'host' => envNonEmpty('DB_HOST', '127.0.0.1'),
'port' => envNonEmpty('DB_PORT', '3306'),
'database' => envNonEmpty('DB_DATABASE', 'forge'),
'username' => envNonEmpty('DB_USERNAME', 'forge'),
2017-09-09 15:32:11 -05:00
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
2018-10-17 08:50:43 -05:00
'engine' => 'InnoDB',
2015-02-07 03:32:15 -06:00
],
2017-09-09 15:32:11 -05:00
'pgsql' => [
2019-03-02 07:33:46 -06:00
'driver' => 'pgsql',
'host' => envNonEmpty('DB_HOST', $host),
'port' => envNonEmpty('DB_PORT', '5432'),
'database' => envNonEmpty('DB_DATABASE', $database),
'username' => envNonEmpty('DB_USERNAME', $username),
'password' => env('DB_PASSWORD', $password),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => envNonEmpty('PGSQL_SSL_MODE', 'prefer'),
'sslcert' => envNonEmpty('PGSQL_SSL_CERT'),
'sslkey' => envNonEmpty('PGSQL_SSL_KEY'),
'sslrootcert' => envNonEmpty('PGSQL_SSL_ROOT_CERT'),
2015-02-07 03:32:15 -06:00
],
2017-09-09 15:32:11 -05:00
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
],
2015-02-07 03:32:15 -06:00
],
2016-11-19 08:55:49 -06:00
'migrations' => 'migrations',
'redis' => [
2017-09-09 15:32:11 -05:00
'client' => 'predis',
2015-02-07 03:32:15 -06:00
'default' => [
2017-09-09 15:32:11 -05:00
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
2016-11-19 08:55:49 -06:00
'port' => env('REDIS_PORT', 6379),
2015-02-07 03:32:15 -06:00
'database' => 0,
],
2017-09-09 15:32:11 -05:00
2015-02-07 03:32:15 -06:00
],
2017-09-09 15:32:11 -05:00
2015-02-05 21:39:52 -06:00
];