fragly/laravel-envsync

A Laravel package that compares and syncs your .env with .env.example for safer CI/CD environments.

Installs: 1

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/fragly/laravel-envsync

v1.0.0 2025-10-25 21:05 UTC

This package is auto-updated.

Last update: 2025-12-25 21:47:00 UTC


README

Packagist Version License Laravel Downloads License Sponsor

Compare and safely synchronize your .env with .env.example.
Perfect for CI/CD pipelines, team development, and clean environments.

Contents

๐Ÿš€ Features

โœ… Compares .env.example โ†” .env
โœ… Shows missing, extra, and same-as-default variables
โœ… Auto-syncs .env with .env.example
โœ… Makes safe backups before changes
โœ… Ignores keys or patterns (APP_KEY, LOG_*, etc.)
โœ… Perfect for automation (non-interactive mode for CI)

๐Ÿงฉ Installation

composer require fragly/laravel-envsync --dev

The serviceprovider is auto-discovered by Laravel.

๐Ÿง  Usage

๐Ÿ” Compare

php artisan env:diff

Example output:

> Checking .env consistency
! Missing in .env:
+ MAIL_ENCRYPTION
+ REDIS_PASSWORD

>> Extra in .env:
+ OLD_DEBUG_FLAG

!! Same-as-default values (check you configured them):
+ APP_NAME
+ APP_ENV
+ APP_DEBUG

Summary: missing=2, extra=1, same-as-default=3

JSON output (for CI)

php artisan env:diff --json

Filter or hide sections

php artisan env:diff --only=missing
php artisan env:diff --hide-defaults
php artisan env:diff --ignore=APP_KEY,LOG_*,REDIS_*

๐Ÿ”„ Sync

Synchronize .env with .env.example.

php artisan env:sync

Options

Option Description
--empty Add missing variables with empty values instead of defaults
--prune Remove keys not present in .env.example
--no-backup Skip creating .env.bak.* backup
--yes Non-interactive (for CI/CD)
--json Output result in JSON
--ignore= Comma-separated ignore list (same syntax as env:diff)

Example

php artisan env:sync --prune --yes --ignore=APP_KEY,LOG_*

๐Ÿงฐ Example workflow (CI/CD)

In your pipeline:

composer install
php artisan env:sync --yes --prune
php artisan config:cache

Keeps environment variables always in sync automatically

โš™๏ธ Configuration

You can create .envsyncignore file in the project root to store patterns ignored in both commands:

APP_KEY
LOG_*
MAIL_*
REDIS_*

๐Ÿงช Local development (testing the package)

If you want to test this package locally without publishing to Packagist:

// in your project's composer.json
{
  "repositories": [
    {
      "type": "path",
      "url": "../package-destination"
    }
  ]
}

Then install it:

composer require fragly/laravel-envsync:@dev

Composer will symlink your package for instant updates.

๐Ÿง‘โ€๐Ÿ’ป About the Author

Fragly Dev โ€” Building tools for modern Laravel & Next.js developers. Follow for more developer utilities, security helpers, and SaaS-ready boilerplates.

๐Ÿ“œ License

This package is open-sourced software licensed under the MIT license.

๐Ÿ” SEO Keywords

laravel env sync, laravel .env compare, laravel .env validator, laravel .env example check,
laravel environment sync, laravel environment tool, laravel environment manager,
laravel ci cd tools, laravel devops utilities, laravel config checker,
laravel configuration sync, laravel dotenv helper, laravel dotenv checker,
laravel deployment tools, laravel config diff, laravel config audit,
laravel .env fixer, laravel production best practices,
laravel environment consistency, laravel config manager, laravel dotenv sync,
laravel automation tools, laravel artisan env command, fragly env sync, fragly laravel package