justcoded/dotenv-sync

This package is abandoned and no longer maintained. No replacement package was suggested.

1.0.1 2020-09-15 16:36 UTC

This package is auto-updated.

Last update: 2023-10-15 23:31:11 UTC


README

The package is intended for avoiding problems with .env and .env.example files content mismatch.

Installation

Start by requiring the package with composer:

composer require justcoded/dotenv-sync

or add it to your composer.json and run composer update

Usage

Add the next line to your git pre-commit hooks (.git/hooks/pre-commit) to prevent committing if .env has params missed in .env.example and vice versa. Ensure the file vendor/bin/dotenv-diff is executable.

exec vendor/bin/dotenv-diff {envFileName} {envExampleFileName}

We also recommend to use this package to manage your git hooks inside composer.json: https://github.com/BrainMaestro/composer-git-hooks

To make bin scripts executable just run:

chmod +x vendor/bin/dotenv-diff vendor/bin/dotenv-sync

To sync missing variables to your .env and .env.example files run the next command

vendor/bin/dotenv-sync {envFileName} {envExampleFileName}

Also you can notify about diff on composer install. To do this add such script to your composer.json:

{
  // ...
  "scripts": {
    "post-install-cmd": [
      "dotenv-diff"
    ],
    "post-update-cmd": [
      "dotenv-diff"
    ]
  }