⌨️ Copy php .env variables to or from Heroku environment variables.
I've created this package because I often use PHP projects/frameworks that use vlucas/phpdotenv package to handle PHP environment values in a .env file.
You can't create/modify files in your Heroku server using Heroku CLI (ok, in fact you can), and you can't create your production .env file, so you have to manually create your environment variables using Heroku CLI or on your Heroku dashboard.
This PHP script can automatically copy environment variables in a .env file to and from Heroku.
This PHP script uses Heroku CLI. You must have installed it on your machine.
Make sure Composer is installed globally.
$ composer global require cba85/heroku-dotenvThen make sure you have the global Composer binaries directory in your PATH.
This directory is platform-dependent, see Composer documentation for details.
$ composer global update cba85/heroku-dotenvGo to your project folder that contains a .env file.
$ heroku-dotenv push -a heroku_app_name$ heroku-dotenv pull heroku_app_nameName or path of your project .env file.
$ heroku-dotenv push heroku_app_name -f .env.production
$ heroku-dotenv pull heroku_app_name -f .env.productionThe package contains a dotenv file for testing, located in example/ folder.
$ ./heroku-dotenv push heroku_app_name -f example/.env
$ ./heroku-dotenv pull heroku_app_name -f example/.envWhere
heroku_app_nameis a valid Heroku app.