setono / deployer-dotenv
Easily update your .env files when deploying
Installs: 21 115
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 2
Forks: 0
Open Issues: 1
pkg:composer/setono/deployer-dotenv
Requires
- php: >=8.1
- deployer/deployer: ^7.5.12
- symfony/console: ^6.4 || ^7.0
- symfony/dotenv: ^6.4 || ^7.0
- webmozart/assert: ^1.11
Requires (Dev)
- phpunit/phpunit: ^10.5
- setono/code-quality-pack: ^2.9
- shipmonk/composer-dependency-analyser: ^1.8.2
This package is auto-updated.
Last update: 2025-10-05 14:25:13 UTC
README
If you use Deployer 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.localfiles as is the default by Deployer. Instead, we have a.env.[stage].localand.env.local.phpin each release folder. -
When deploying, we copy the
.env.[stage].localfile 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.phpfile for the current release.
Installation
composer require setono/deployer-dotenv
Usage
In your deploy.php file require the recipe:
<?php namespace Deployer; require_once 'recipe/setono_dotenv.php'; // ...
This will automatically hook into the default flow of Deployer.