|
| 1 | +<?php |
| 2 | + |
| 3 | +use Illuminate\Support\Str; |
| 4 | + |
| 5 | +$url = parse_url(getenv('DATABASE_URL')); |
| 6 | +$redis_url = parse_url(getenv('REDIS_URL')); |
| 7 | + |
| 8 | +return [ |
| 9 | + |
| 10 | + /* |
| 11 | + |-------------------------------------------------------------------------- |
| 12 | + | Default Database Connection Name |
| 13 | + |-------------------------------------------------------------------------- |
| 14 | + | |
| 15 | + | Here you may specify which of the database connections below you wish |
| 16 | + | to use as your default connection for all database work. Of course |
| 17 | + | you may use many connections at once using the Database library. |
| 18 | + | |
| 19 | + */ |
| 20 | + |
| 21 | + 'default' => env('DB_CONNECTION', 'mysql'), |
| 22 | + |
| 23 | + /* |
| 24 | + |-------------------------------------------------------------------------- |
| 25 | + | Database Connections |
| 26 | + |-------------------------------------------------------------------------- |
| 27 | + | |
| 28 | + | Here are each of the database connections setup for your application. |
| 29 | + | Of course, examples of configuring each database platform that is |
| 30 | + | supported by Laravel is shown below to make development simple. |
| 31 | + | |
| 32 | + | |
| 33 | + | All database work in Laravel is done through the PHP PDO facilities |
| 34 | + | so make sure you have the driver for your particular database of |
| 35 | + | choice installed on your machine before you begin development. |
| 36 | + | |
| 37 | + */ |
| 38 | + |
| 39 | + 'connections' => [ |
| 40 | + |
| 41 | + 'sqlite' => [ |
| 42 | + 'driver' => 'sqlite', |
| 43 | + 'url' => env('DATABASE_URL'), |
| 44 | + 'database' => env('DB_DATABASE', database_path('database.sqlite')), |
| 45 | + 'prefix' => '', |
| 46 | + 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), |
| 47 | + ], |
| 48 | + |
| 49 | + 'mysql' => [ |
| 50 | + 'driver' => 'mysql', |
| 51 | + 'url' => env('DATABASE_URL'), |
| 52 | + 'host' => env('DB_HOST', '127.0.0.1'), |
| 53 | + 'port' => env('DB_PORT', '3306'), |
| 54 | + 'database' => env('DB_DATABASE', 'forge'), |
| 55 | + 'username' => env('DB_USERNAME', 'forge'), |
| 56 | + 'password' => env('DB_PASSWORD', ''), |
| 57 | + 'unix_socket' => env('DB_SOCKET', ''), |
| 58 | + 'charset' => 'utf8mb4', |
| 59 | + 'collation' => 'utf8mb4_unicode_ci', |
| 60 | + 'prefix' => '', |
| 61 | + 'prefix_indexes' => true, |
| 62 | + 'strict' => true, |
| 63 | + 'engine' => null, |
| 64 | + 'options' => extension_loaded('pdo_mysql') ? array_filter([ |
| 65 | + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), |
| 66 | + ]) : [], |
| 67 | + ], |
| 68 | + |
| 69 | + 'pgsql' => [ |
| 70 | + 'driver' => 'pgsql', |
| 71 | + 'url' => env('DATABASE_URL'), |
| 72 | + 'host' => env('DB_HOST', '127.0.0.1'), |
| 73 | + 'port' => env('DB_PORT', '5432'), |
| 74 | + 'database' => env('DB_DATABASE', 'forge'), |
| 75 | + 'username' => env('DB_USERNAME', 'forge'), |
| 76 | + 'password' => env('DB_PASSWORD', ''), |
| 77 | + 'charset' => 'utf8', |
| 78 | + 'prefix' => '', |
| 79 | + 'prefix_indexes' => true, |
| 80 | + 'schema' => 'public', |
| 81 | + 'sslmode' => 'prefer', |
| 82 | + ], |
| 83 | + |
| 84 | + 'sqlsrv' => [ |
| 85 | + 'driver' => 'sqlsrv', |
| 86 | + 'url' => env('DATABASE_URL'), |
| 87 | + 'host' => env('DB_HOST', 'localhost'), |
| 88 | + 'port' => env('DB_PORT', '1433'), |
| 89 | + 'database' => env('DB_DATABASE', 'forge'), |
| 90 | + 'username' => env('DB_USERNAME', 'forge'), |
| 91 | + 'password' => env('DB_PASSWORD', ''), |
| 92 | + 'charset' => 'utf8', |
| 93 | + 'prefix' => '', |
| 94 | + 'prefix_indexes' => true, |
| 95 | + ], |
| 96 | + |
| 97 | + 'heroku' => [ |
| 98 | + 'driver' => 'pgsql', |
| 99 | + 'host' => isset($url['host']) ? $url['host'] : env('DB_HOST', '127.0.0.1'), |
| 100 | + 'database' => isset($url['path']) ? substr($url['path'], 1) : env('DB_DATABASE', 'forge'), |
| 101 | + 'username' => isset($url['user']) ? $url['user'] : env('DB_USERNAME', 'forge'), |
| 102 | + 'password' => isset($url['pass']) ? $url['pass'] : env('DB_PASSWORD', ''), |
| 103 | + 'charset' => 'utf8', |
| 104 | + 'prefix' => '', |
| 105 | + 'schema' => 'public', |
| 106 | + ], |
| 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 body of commands than a typical key-value system |
| 130 | + | such as APC or Memcached. Laravel makes it easy to dig right in. |
| 131 | + | |
| 132 | + */ |
| 133 | + |
| 134 | + 'redis' => [ |
| 135 | + |
| 136 | + 'client' => env('REDIS_CLIENT', 'phpredis'), |
| 137 | + |
| 138 | + 'options' => [ |
| 139 | + 'cluster' => env('REDIS_CLUSTER', 'redis'), |
| 140 | + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), |
| 141 | + ], |
| 142 | + |
| 143 | + 'default' => [ |
| 144 | + 'host' => isset($redis_url['host']) ? $redis_url['host'] : env('REDIS_HOST', '127.0.0.1'), |
| 145 | + 'password' => isset($redis_url['pass']) ? $redis_url['pass'] : env('REDIS_PASSWORD', null), |
| 146 | + 'port' => isset($redis_url['port']) ? $redis_url['port'] : env('REDIS_PORT', 6379), |
| 147 | + 'database' => env('REDIS_DB', '0'), |
| 148 | + ], |
| 149 | + |
| 150 | + 'cache' => [ |
| 151 | + 'host' => isset($redis_url['host']) ? $redis_url['host'] : env('REDIS_HOST', '127.0.0.1'), |
| 152 | + 'password' => isset($redis_url['pass']) ? $redis_url['pass'] : env('REDIS_PASSWORD', null), |
| 153 | + 'port' => isset($redis_url['port']) ? $redis_url['port'] : env('REDIS_PORT', 6379), |
| 154 | + 'database' => env('REDIS_CACHE_DB', '1'), |
| 155 | + ], |
| 156 | + |
| 157 | + ], |
| 158 | + |
| 159 | +]; |
0 commit comments