dev-master
9999999-devSimple connect to herokupostgres for php-applications
MIT
The Development Requires
by Oleg Popadko
database environment parameters management heroku
Wallogit.com
2017 © Pedro Peláez
Simple connect to herokupostgres for php-applications
Simple connect to herokupostgres for php-applications, (*1)
Add the following in your root composer.json file:, (*2)
{
"require": {
"olegpopadko/composer-heroku-database-environment": "dev-master"
},
"scripts": {
"post-install-cmd": [
"OlegPopadko\\HerokuDatabaseEnvironment\\Composer\\EnvironmentHandler::expand"
]
}
}
EnvironmentHandler divides DATABASE_URL environment variable and expands your environment with new five variables., (*3)
After composer install you will have something like this in your environment, (*4)
DATABASE_URL=postgres://user:password@database.host:5432/database_name DATABASE_HOST=database.host DATABASE_PORT=5432 DATABASE_USER=user DATABASE_PASSWORD=password DATABASE_NAME=database_name
Now you can easily setup your app with Heroku database credentials., (*5)
You can setup it in composer.json like this:, (*6)
{
"scripts": {
"post-install-cmd": [
"OlegPopadko\\HerokuDatabaseEnvironment\\Composer\\EnvironmentHandler::expand",
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
]
},
"extra": {
"incenteev-parameters": {
"file": "app/config/parameters.yml",
"env-map": {
"database_host": "DATABASE_HOST",
"database_port": "DATABASE_PORT",
"database_name": "DATABASE_NAME",
"database_user": "DATABASE_USER",
"database_password": "DATABASE_PASSWORD"
}
}
}
}
Note: EnvironmentHandler::expand must be executed before ScriptHandler::buildParameters., (*7)
It's would be usefull if you are using Symfony., (*8)
Simple connect to herokupostgres for php-applications
MIT
database environment parameters management heroku