mahbubhelal/sync-env
最新稳定版本:1.0
Composer 安装命令:
composer require --dev mahbubhelal/sync-env
包简介
A laravel package to sync env variables between different .env files.
README 文档
README
A highly opinionated Laravel package to sync environment variables between different .env files and view differences between them. Ensures all your .env files are consistent, clean, and strictly follow best practices for key/value formatting.
Features
- Strict .env key rules: Only allows keys that are upper snake case, starting with an uppercase letter or underscore, and containing only uppercase letters, numbers, or underscores.
- No leading/trailing spaces: No line in any
.envfile may have leading or trailing spaces. Values must not have leading spaces. - Identical structure: The synced
.envfiles will have the exact same structure, order, comments, and blank lines as.env.example, differing only in values where present. - Sync .env files: Synchronize keys from
.env.exampleto all other.env*files, preserving existing values and creating backups. - Show diffs: View differences between
.env.exampleand other.envfiles, including options to show all keys or include backup files. - Backup management: Automatically create backups before syncing, and remove old backups with options.
Key Format Rules
- Keys must be in UPPER_SNAKE_CASE.
- Keys must start with an uppercase letter (
A-Z) or underscore (_). - Keys may only contain uppercase letters (
A-Z), numbers (0-9), and underscores (_). - No leading or trailing spaces are allowed in any line.
- Values must not have leading spaces.
Examples
Valid keys:
APP_NAME
_DB_CONNECTION
FOO_BAR_123
Invalid keys:
app_name # not uppercase
APP_NAME # leading space
APP-NAME # dash not allowed
APP NAME # space not allowed
APP@NAME # special char not allowed
Invalid values:
APP_NAME= MyApp # leading space in value
Installation
composer require mahbubhelal/sync-env
Usage
1. Sync .env files
Synchronize .env.example to all other .env* files:
php artisan sync-env:example-to-envs
Options:
--no-backup(-N): Do not create a backup of the target.envfile before syncing.--remove-backups(-r): Remove previously created backup files before syncing.
2. Show differences between .env files
Display differences between .env.example and other .env files:
php artisan sync-env:show-diffs
Options:
--all(-a): Show all keys, including identical ones.--include-backup(-b): Include backup files in the diff view.
Example Workflow
- Update your
.env.examplefile with new keys or changes, following the strict key/value rules above. - Run the sync command to propagate changes to all
.envfiles:php artisan sync-env:example-to-envs
- Use the show-diffs command to review differences:
php artisan sync-env:show-diffs
Testing
Run tests with Pest:
vendor/bin/pest
License
MIT
Author: Md Mahbub Helal (mdhelal00@gmail.com)
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-27