{"id":15063064,"url":"https://github.com/marcinorlowski/process-dotenv","last_synced_at":"2025-10-25T04:47:44.211Z","repository":{"id":54814204,"uuid":"56245188","full_name":"MarcinOrlowski/process-dotenv","owner":"MarcinOrlowski","description":"Little tool to help build DotEnv (.env) files from templates. Try it with your CI setup!","archived":false,"fork":false,"pushed_at":"2021-01-27T16:47:08.000Z","size":15,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T13:51:18.985Z","etag":null,"topics":["ci","continuous-integration","dot-environment","jenkins","php","teamcity","tools","travis-ci"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarcinOrlowski.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-14T14:40:23.000Z","updated_at":"2023-04-25T06:32:06.000Z","dependencies_parsed_at":"2022-08-14T03:40:27.073Z","dependency_job_id":null,"html_url":"https://github.com/MarcinOrlowski/process-dotenv","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcinOrlowski%2Fprocess-dotenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcinOrlowski%2Fprocess-dotenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcinOrlowski%2Fprocess-dotenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarcinOrlowski%2Fprocess-dotenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarcinOrlowski","download_url":"https://codeload.github.com/MarcinOrlowski/process-dotenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199244,"owners_count":21063641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","continuous-integration","dot-environment","jenkins","php","teamcity","tools","travis-ci"],"created_at":"2024-09-24T23:50:51.227Z","updated_at":"2025-10-25T04:47:39.174Z","avatar_url":"https://github.com/MarcinOrlowski.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Process DotEnv - .env building helper tool #\n\n[![Latest Stable Version](https://poser.pugx.org/marcin-orlowski/process-dotenv/v/stable)](https://packagist.org/packages/marcin-orlowski/process-dotenv)\n[![Latest Unstable Version](https://poser.pugx.org/marcin-orlowski/process-dotenv/v/unstable)](https://packagist.org/packages/marcin-orlowski/process-dotenv)\n[![License](https://poser.pugx.org/marcin-orlowski/process-dotenv/license)](https://packagist.org/packages/marcin-orlowski/process-dotenv)\n\n`.env` (AKA DotEnv) files are often used to store project configuration (i.e. for [Laravel](https://laravel.com/)\nbased PHP projects). As they usually contain sensitive information as API keys or DB credentials, `.env` files should\nnever be versioned. This also means that if you need to use/run your project in automated pipeline, i.e. with \nContinuous Integration (CI) tools like TeamCity or Travis-CI, you need to create proper `.env` file before using the\ncode. As `.env` file usually contains all the project configuration, there will be much more fields than said i.e.\nAPI key. Additionally, as project develops, new entries can be added and existing entries altered or tweaked.\nIt's a developers' common practice to create `.env.dist` file, fill as much as possible (ommiting sensitive information)\nand put it into VCS. \n\nSo if we treat said `.env.dist` as **template file**, then with the right tool in hand we'd be able to\ncreate corresponding `.env` file easily. And this is where `process-dotenv` steps in. The goal of this \nsmall tool is pretty simple - generate `.env` file based on the template `.env.dist`, filling/replacing\nspecified template keys with provided values (taken either from env vars, for supplied as invocation\narguments).\n\n**NOTE:** Whenever I say `.env` or `.env.dist` I only mean **file format**, not file name. Your\nfile names can be anything you like as long its content follows dot-env file format!\n\n**NOTE:** To avoid accidental overwrites `process-dotenv` outputs processed content to standard output. To to\ncreate physical `.env` file need to redirect stdout to a file. Please see examples for more details.\n\n## Env variable subsitution ##\n\n**NOTE:** all samples mimics shell session, so ommit `$` line for use in scripts.:\n\nLet's assume our `.env.dist` template file looks like this:\n\n    KEY=val\n    BAR=zen\n    FOO=\n\nNow, knowing your app requires `KEY` to be valid API key for tests to pass we can have it replaced with \n`process-dotenv`:\n\n    $ KEY=barbar\n    $ vendor/bin/process-dotenv .env.dist \u003e .env\n\nwhich shall produce `.env` file with the following content:\n\n    KEY=barbar\n    BAR=zen\n    FOO=\n\nAs you noticed, original value of `KEY` is replaced with what we provided via enviromental variable,\nwhile `BAR` and `FOO`, for which we did not provide replacements, were copied unaltered.\n\n\n## Argument subsitution ##\n\nAside of env variables you can also pass `key=val` pairs as `process-dotenv` invocation arguments to\nachieve the same results:\n\n    $ vendor/bin/process-dotenv .env.dist KEY=barbar \u003e .env\n\n**IMPORTANT:** first argument always refers to source dot-env file, followed by (optional) `KEY=VAL` pairs.\nYou can pass as many pairs as you need and file names can be whatever you like.\n\n## Combined substitution ##\n\nBoth substitution methods can be used together. When key is provided as argument and\nalso exists as enviromental variable, then command line provided value takes precedence:\n\n    $ KEY=barbar\n    $ vendor/bin/process-dotenv .env.dist KEY=value \u003e .env\n\nwould produce:\n\n    KEY=value\n    BAR=zen\n    FOO=\n\n\n## Requirements ##\n\n * PHP 5+ (CLI)\n \n## Installation ##\n\nUse composer to install this package as your dependency:\n\n    $ composer require marcin-orlowski/process-dotenv\n\nIt will install `process-dotenv` script in usual `vendor/bin` folder.\n\n\n## Troubleshoting ##\n\nPlease remember that certain, especially generic key names can already be set up by\nyour shell or system. For example `USER` is usually present and holds id of currently logged\nin user,`HOME` points to home directory of said user are variables already\nset, etc. You can list all of them with `printenv` or `export` to ensure none of your keys\nmatches, but it is good habit to be more creative and avoid such short and potentially conflicting\nnames.\n\nSimple test to see if your `.env.dist` uses such \"risky\" keys is to run `process-dotenv`\nwithout any own substitution provided and diff result file with dist file:\n\n    $ vendor/bin/process-dotenv .env.dist | diff .env.dist\n\nIf you got conflicts then you can either change your keys or at least substitute that key\nvia command line arguments to ensure system's values won't pollute your resulting `.env`:\n\n    $ vendor/bin/process-dotenv .env.dist USER= HOME= \u003e .env\n\nbut this is pretty error prone and is not recommended.\n\n**NOTE:** in case you use conflicting key (i.e. `USER`) but you want it to keep the\nvalue set in `.env.dist` you currently must pass it as command like pair. `process-dotenv` \ncannot tell which env variables is \"good\" and which is \"bad\", so as soon as it find one exists,\nit will simply use its value. That's why you must override it via command line pair.\n\n## License ##\n\n* Copyright \u0026copy; 2016-2021 by Marcin Orlowski\n* Process Dotenv tool is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinorlowski%2Fprocess-dotenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcinorlowski%2Fprocess-dotenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcinorlowski%2Fprocess-dotenv/lists"}