Last active
March 25, 2019 19:17
-
-
Save sgasser/81850ad446580e2f4a995cb95dc499f0 to your computer and use it in GitHub Desktop.
database.php for Heroku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dbHost = env('DB_HOST', '127.0.0.1'); | |
$dbPort = env('DB_PORT', '5432'); | |
$dbName = env('DB_DATABASE', 'forge'); | |
$dbUser = env('DB_USERNAME', 'forge'); | |
$dbPassword = env('DB_PASSWORD', ''); | |
if (env('DATABASE_URL')) { | |
$databaseUrl = parse_url(env('DATABASE_URL')); | |
$dbHost = $databaseUrl['host']; | |
$dbPort = $databaseUrl['port']; | |
$dbName = substr($databaseUrl['path'], 1); | |
$dbUser = $databaseUrl['user']; | |
$dbPassword = $databaseUrl['pass']; | |
} | |
$redisHost = env('REDIS_HOST', '127.0.0.1'); | |
$redisPort = env('REDIS_PORT', 6379); | |
$redisPassword = env('REDIS_PASSWORD', null); | |
if (env('REDIS_URL')) { | |
$redisUrl = parse_url(env('REDIS_URL')); | |
$redisHost = $redisUrl['host']; | |
$redisPort = $redisUrl['port']; | |
$redisPassword = $redisUrl['pass']; | |
} | |
return [ | |
/* | |
|-------------------------------------------------------------------------- | |
| Default Database Connection Name | |
|-------------------------------------------------------------------------- | |
| | |
| Here you may specify which of the database connections below you wish | |
| to use as your default connection for all database work. Of course | |
| you may use many connections at once using the Database library. | |
| | |
*/ | |
'default' => env('DB_CONNECTION', 'pgsql'), | |
/* | |
|-------------------------------------------------------------------------- | |
| Database Connections | |
|-------------------------------------------------------------------------- | |
| | |
| Here are each of the database connections setup for your application. | |
| Of course, examples of configuring each database platform that is | |
| supported by Laravel is shown below to make development simple. | |
| | |
| | |
| All database work in Laravel is done through the PHP PDO facilities | |
| so make sure you have the driver for your particular database of | |
| choice installed on your machine before you begin development. | |
| | |
*/ | |
'connections' => [ | |
'pgsql' => [ | |
'driver' => 'pgsql', | |
'host' => $dbHost, | |
'port' => $dbPort, | |
'database' => $dbName, | |
'username' => $dbUser, | |
'password' => $dbPassword, | |
'charset' => 'utf8', | |
'prefix' => '', | |
'prefix_indexes' => true, | |
'schema' => 'public', | |
'sslmode' => 'prefer', | |
], | |
], | |
/* | |
|-------------------------------------------------------------------------- | |
| Redis Databases | |
|-------------------------------------------------------------------------- | |
| | |
| Redis is an open source, fast, and advanced key-value store that also | |
| provides a richer body of commands than a typical key-value system | |
| such as APC or Memcached. Laravel makes it easy to dig right in. | |
| | |
*/ | |
'redis' => [ | |
'client' => env('REDIS_CLIENT', 'predis'), | |
'options' => [ | |
'cluster' => env('REDIS_CLUSTER', 'predis'), | |
], | |
'default' => [ | |
'host' => $redisHost, | |
'password' => $redisPassword, | |
'port' => $redisPort, | |
'database' => env('REDIS_DB', 0), | |
], | |
'cache' => [ | |
'host' => $redisHost, | |
'password' => $redisPassword, | |
'port' => $redisPort, | |
'database' => env('REDIS_CACHE_DB', 1), | |
], | |
], | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment