PHPackages                             setono/deployer-dotenv - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. setono/deployer-dotenv

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

setono/deployer-dotenv
======================

Easily update your .env files when deploying

v1.3.0(3y ago)921.3k↓50%[1 issues](https://github.com/Setono/deployer-dotenv/issues)MITPHPPHP &gt;=7.4CI passing

Since Oct 23Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Setono/deployer-dotenv)[ Packagist](https://packagist.org/packages/setono/deployer-dotenv)[ RSS](/packages/setono-deployer-dotenv/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (8)Dependencies (6)Versions (10)Used By (0)

DotEnv handling with Deployer
=============================

[](#dotenv-handling-with-deployer)

[![Latest Version](https://camo.githubusercontent.com/b06df6005c1872f8a4fdf9597765dd99d943f38ad1926b8ffe5cb715d921917d/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f6465706c6f7965722d646f74656e762f762f737461626c65)](https://packagist.org/packages/setono/deployer-dotenv)[![Software License](https://camo.githubusercontent.com/45e768cf8bbbf75c98594c933920532f1a76754fcecdd6044ec882e605188d5d/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f6465706c6f7965722d646f74656e762f6c6963656e7365)](LICENSE)[![Build Status](https://github.com/Setono/deployer-dotenv/workflows/build/badge.svg)](https://github.com/Setono/deployer-dotenv/actions)

If you use [Deployer](https://deployer.org/) as your deployment tool and `.env` files to handle environment variables (i.e., Symfony) this library is for you.

Are you still accessing your server to update environment variables manually after a deployment? We also did that, and that's the main reason why we built this library.

Now we have a very specific, but simple, strategy for updating the `.env` files during deployment:

- We do **not** share the `.env.local.php`, `.env.local` files as is the default by Deployer. Instead, we have a `.env.[stage].local` and `.env.local.php` in each release folder.
- When deploying, we copy the `.env.[stage].local` file from the previous release (if there was a previous release, else we create it).
- If you’re deploying interactively (i.e., manually), you’re presented with a dialog asking if you want to update any environment variables.
- Finally, we run `composer symfony:dump-env [stage]` to generate the `.env.local.php` file for the current release.

Installation
------------

[](#installation)

```
composer require setono/deployer-dotenv
```

Usage
-----

[](#usage)

In your `deploy.php` file require the recipe:

```
