Skip to content

⌨️ Copy php `.env` variables to or from Heroku environment variables.

Notifications You must be signed in to change notification settings

cba85/heroku-dotenv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heroku Dotenv

⌨️ Copy php .env variables to or from Heroku environment variables.

Why creating this package?

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.

Requirements

Heroku CLI

This PHP script uses Heroku CLI. You must have installed it on your machine.

Composer

Make sure Composer is installed globally.

Install

$ composer global require cba85/heroku-dotenv

Then make sure you have the global Composer binaries directory in your PATH.

This directory is platform-dependent, see Composer documentation for details.

Update

$ composer global update cba85/heroku-dotenv

Usage

Go to your project folder that contains a .env file.

Send .env file to Heroku environment

$ heroku-dotenv push -a heroku_app_name

Save Heroku environment to .env file

$ heroku-dotenv pull heroku_app_name

Options

-f, --file

Name or path of your project .env file.

$ heroku-dotenv push heroku_app_name -f .env.production
$ heroku-dotenv pull heroku_app_name -f .env.production

Tests

The 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/.env

Where heroku_app_name is a valid Heroku app.

About

⌨️ Copy php `.env` variables to or from Heroku environment variables.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages