A powerful Laravel package for synchronizing environment files with interactive prompts and intelligent conflict resolution. EnvSync helps you keep your .env, .env.example, .env.production and other environment files in perfect harmony.
Caution
🤖🧠 This Package was vibe coded 🤖🧠
Key Features:
- 🔄 Interactive Sync: Per-key prompts for differing values with sync, ignore, or permanent ignore options
- 🚫 Smart Ignoring: Use
#ENVIGNOREcomments to permanently ignore specific environment variables - 📁 Structure Preservation: Maintains file formatting, comments, and organization
- ⚡ Auto-sync Mode: Automatically sync all differences without prompts
- 🔒 Version Control Aware: Handles version-controlled files intelligently
You can install the package via composer:
composer require blemli/envsyncSync your .env file with .env.example:
php artisan env:syncSync with a different target file:
php artisan env:sync --path=.env.productionWhen differences are detected, you'll get interactive prompts for each differing key:
Key 'DATABASE_URL' has different values:
.env: 'mysql://localhost/prod_db'
.env.example: 'mysql://localhost/example_db'
What would you like to do with this key?
[0] Sync from .env to .env.example
[1] Ignore once (skip this time only)
[2] Forever ignore (add #ENVIGNORE to this line)
[3] Quit without making changes
Automatically sync all differing values without prompts:
php artisan env:sync --auto-syncSkip all confirmation prompts and apply all changes automatically:
php artisan env:sync --forceAdd #ENVIGNORE to any line in your target file to permanently ignore differences for that key:
# .env.example
APP_NAME=ExampleApp
DATABASE_URL=mysql://localhost/example_db #ENVIGNORE
API_KEY=your_api_key_hereThe DATABASE_URL line will be ignored in all future sync operations.
Scenario 1: New developer setup
# Copy .env.example to .env, then sync any missing keys
cp .env.example .env
php artisan env:sync --path=.env.exampleScenario 2: Production deployment
# Sync production environment file
php artisan env:sync --path=.env.production --auto-syncScenario 3: Team collaboration
# Interactive sync to review each difference
php artisan env:sync --path=.env.example| Option | Description |
|---|---|
--path=FILE |
Target file to sync with (default: .env.example) |
--force |
Skip all confirmation prompts and apply changes automatically |
--auto-sync |
Automatically sync all differing values from source to target |
- Missing Keys: Prompts to add keys that exist in source but not in target
- Extra Keys: Prompts to remove keys that exist in target but not in source
- Differing Values: Interactive prompts with options to sync, ignore once, or ignore forever
- Version Control: Automatically detects version-controlled files and handles them appropriately
- Structure Preservation: Maintains original file formatting, comments, and organization
composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.