Skip to content

Instantly share code, notes, and snippets.

@kjohnson
Created February 17, 2018 03:44
Show Gist options
  • Select an option

  • Save kjohnson/c9281489dbe642b3ca07654f311c6b7c to your computer and use it in GitHub Desktop.

Select an option

Save kjohnson/c9281489dbe642b3ca07654f311c6b7c to your computer and use it in GitHub Desktop.
A Heroku PostgreSQL connection for Laravel
<?php
return [
'connections' => [
'heroku_pgsql' => [
'driver' => 'pgsql',
'host' => @parse_url(getenv("DATABASE_URL"))['host'],
'port' => env('DB_PORT', '5432'),
'database' => @substr(parse_url(getenv("DATABASE_URL"))['path'],1),
'username' => @parse_url(getenv("DATABASE_URL"))['user'],
'password' => @parse_url(getenv("DATABASE_URL"))['pass'],
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
],
];
@kjohnson
Copy link
Author

The @ suppresses the Notice: Undefined index. message for local development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment