Download the PHP package marcin-orlowski/process-dotenv without Composer

On this page you can find all versions of the php package marcin-orlowski/process-dotenv. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package process-dotenv

Process DotEnv - .env building helper tool

Latest Stable Version Latest Unstable Version License

.env (AKA DotEnv) files are often used to store project configuration (i.e. for Laravel based PHP projects). As they usually contain sensitive information as API keys or DB credentials, .env files should never be versioned. This also means that if you need to use/run your project in automated pipeline, i.e. with Continuous Integration (CI) tools like TeamCity or Travis-CI, you need to create proper .env file before using the code. As .env file usually contains all the project configuration, there will be much more fields than said i.e. API key. Additionally, as project develops, new entries can be added and existing entries altered or tweaked. It's a developers' common practice to create .env.dist file, fill as much as possible (ommiting sensitive information) and put it into VCS.

So if we treat said .env.dist as template file, then with the right tool in hand we'd be able to create corresponding .env file easily. And this is where process-dotenv steps in. The goal of this small tool is pretty simple - generate .env file based on the template .env.dist, filling/replacing specified template keys with provided values (taken either from env vars, for supplied as invocation arguments).

NOTE: Whenever I say .env or .env.dist I only mean file format, not file name. Your file names can be anything you like as long its content follows dot-env file format!

NOTE: To avoid accidental overwrites process-dotenv outputs processed content to standard output. To to create physical .env file need to redirect stdout to a file. Please see examples for more details.

Env variable subsitution

NOTE: all samples mimics shell session, so ommit $ line for use in scripts.:

Let's assume our .env.dist template file looks like this:

KEY=val
BAR=zen
FOO=

Now, knowing your app requires KEY to be valid API key for tests to pass we can have it replaced with process-dotenv:

$ KEY=barbar
$ vendor/bin/process-dotenv .env.dist > .env

which shall produce .env file with the following content:

KEY=barbar
BAR=zen
FOO=

As you noticed, original value of KEY is replaced with what we provided via enviromental variable, while BAR and FOO, for which we did not provide replacements, were copied unaltered.

Argument subsitution

Aside of env variables you can also pass key=val pairs as process-dotenv invocation arguments to achieve the same results:

$ vendor/bin/process-dotenv .env.dist KEY=barbar > .env

IMPORTANT: first argument always refers to source dot-env file, followed by (optional) KEY=VAL pairs. You can pass as many pairs as you need and file names can be whatever you like.

Combined substitution

Both substitution methods can be used together. When key is provided as argument and also exists as enviromental variable, then command line provided value takes precedence:

$ KEY=barbar
$ vendor/bin/process-dotenv .env.dist KEY=value > .env

would produce:

KEY=value
BAR=zen
FOO=

Requirements

Installation

Use composer to install this package as your dependency:

$ composer require marcin-orlowski/process-dotenv

It will install process-dotenv script in usual vendor/bin folder.

Troubleshoting

Please remember that certain, especially generic key names can already be set up by your shell or system. For example USER is usually present and holds id of currently logged in user,HOME points to home directory of said user are variables already set, etc. You can list all of them with printenv or export to ensure none of your keys matches, but it is good habit to be more creative and avoid such short and potentially conflicting names.

Simple test to see if your .env.dist uses such "risky" keys is to run process-dotenv without any own substitution provided and diff result file with dist file:

$ vendor/bin/process-dotenv .env.dist | diff .env.dist

If you got conflicts then you can either change your keys or at least substitute that key via command line arguments to ensure system's values won't pollute your resulting .env:

$ vendor/bin/process-dotenv .env.dist USER= HOME= > .env

but this is pretty error prone and is not recommended.

NOTE: in case you use conflicting key (i.e. USER) but you want it to keep the value set in .env.dist you currently must pass it as command like pair. process-dotenv cannot tell which env variables is "good" and which is "bad", so as soon as it find one exists, it will simply use its value. That's why you must override it via command line pair.

License


All versions of process-dotenv with dependencies

PHP Build Version
Package Version
Requires php Version >=5.1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package marcin-orlowski/process-dotenv contains the following files

Loading the files please wait ....