Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

justcoded/dotenv-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"
    ]
  }

About

Avoiding problems with .env and .env.example files content mismatch.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages