2017 © Pedro Peláez
 

library laravel-heroku-config-parser

Parse Heroku config vars like DATABASE_URL or REDIS_URL to work with Laravel.

image

itsdamien/laravel-heroku-config-parser

Parse Heroku config vars like DATABASE_URL or REDIS_URL to work with Laravel.

  • Monday, May 28, 2018
  • by itsDamien
  • Repository
  • 1 Watchers
  • 4 Stars
  • 10,789 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 10 % Grown

The README.md

Laravel Heroku Config Parser

Latest Stable Version Total Downloads License Build Status Maintainability Test Coverage StyleCI, (*1)

Parse Heroku config vars like DATABASE_URL or REDIS_URL to work with Laravel., (*2)

Important

Due to a breaking change in Laravel 5.8 (thanks https://github.com/mathieutu for the feedback), you can use this method to achieve the same goal:, (*3)

https://github.com/itsDamien/laravel-heroku-config-parser/issues/2#issuecomment-469709141, (*4)

Breaking change:

https://github.com/laravel/framework/issues/27695, (*5)

https://github.com/laravel/docs/pull/5039, (*6)

Why

When adding a database or a redis server to your Heroku app, Heroku add a URL config var like this: DATABASE_URL=postgres://usr:pwd@localhost:5432/hellodb, (*7)

Unfortunately, Laravel can't read this var, so you probably parsed it manually like this:, (*8)

heroku config:set DB_CONNECTION=pgsql
heroku config:set DB_HOST=localhost
heroku config:set DB_PORT=5432
heroku config:set DB_DATABASE=hellodb
heroku config:set DB_USERNAME=usr
heroku config:set DB_PASSWORD=pwd

Laravel Heroku Config Parser parse automatically your DATABASE_URL and REDIS_URL to dynamically set all vars needed by Laravel (see the list)., (*9)

Installation

Installation using composer:, (*10)

composer require itsdamien/laravel-heroku-config-parser

Heroku

Add these config vars:, (*11)

heroku config:set KEY_DATABASE=DATABASE_URL
heroku config:set KEY_REDIS=REDIS_URL

Laravel

Add this block code to the top of your config/database.php:, (*12)

if (class_exists('\ItsDamien\Heroku\Config\Parse')) {
    new \ItsDamien\Heroku\Config\Parse();
}

Enjoy !, (*13)

ENV vars created

DATABASE_URL postgres://usr:pwd@ec2-s1:5432/db1 mysql://usr:pwd@ec2-s2:3306/db2
DB_CONNECTION pgsql mysql
DB_HOST       ec2-s1                         ec2-s2                    
DB_PORT       5432                           3306                      
DB_DATABASE db1 db2
DB_USERNAME usr usr
DB_PASSWORD   pwd                           pwd                        
REDIS_URL redis://h:pwd@ec2-s1:11469
REDIS_HOST ec2-s1
REDIS_PORT 11469
REDIS_PASSWORD pwd

Customize the config var who will be parsed

You can select wich config var will be parsed by setting KEY_DATABASE and KEY_REDIS like this:, (*14)

heroku config:set KEY_DATABASE=HEROKU_POSTGRESQL_BRONZE
heroku config:set KEY_REDIS=REDIS_URL_BACKUP

License

Laravel Heroku Config Parser is open-sourced software licensed under the MIT license, (*15)

The Versions

28/05 2018

dev-master

9999999-dev

Parse Heroku config vars like DATABASE_URL or REDIS_URL to work with Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damien Criado

database laravel redis env heroku

23/08 2017

v1.1

1.1.0.0

Parse Heroku config vars like DATABASE_URL or REDIS_URL to work with Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damien Criado

database laravel redis env heroku

06/03 2017

v1.0.2

1.0.2.0

Parse Heroku config vars like DATABASE_URL or REDIS_URL to work with Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damien Criado

database laravel redis env heroku

02/03 2017

v1.0.1

1.0.1.0

Parse Heroku config vars like DATABASE_URL or REDIS_URL to work with Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.6.4

 

by Damien Criado

database laravel redis env heroku

01/03 2017

v1.0

1.0.0.0

Parse Heroku config vars like DATABASE_URL or REDIS_URL to work with Laravel.

  Sources   Download

MIT

The Requires

  • php >=5.6.4

 

by Damien Criado

database laravel redis env heroku