firefly-iii/config/database.php

99 lines
3.1 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 = '';
2017-11-29 09:26:00 -06:00
if (!($databaseUrl === false)) {
$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 [
2017-09-09 15:32:11 -05:00
'default' => env('DB_CONNECTION', 'mysql'),
2015-02-07 03:32:15 -06:00
'connections' => [
'sqlite' => [
2016-11-19 08:55:49 -06:00
'driver' => 'sqlite',
'database' => env('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',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
2015-02-07 03:32:15 -06:00
],
2017-09-09 15:32:11 -05:00
'pgsql' => [
2016-11-19 08:55:49 -06:00
'driver' => 'pgsql',
2017-11-29 09:23:17 -06:00
'host' => env('DB_HOST', $host),
2016-11-19 08:55:49 -06:00
'port' => env('DB_PORT', '5432'),
2017-11-29 09:23:17 -06:00
'database' => env('DB_DATABASE', $database),
'username' => env('DB_USERNAME', $username),
'password' => env('DB_PASSWORD', $password),
2016-11-19 08:55:49 -06:00
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
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
];