Giter VIP home page Giter VIP logo

laravel-env-sync's Introduction

Tests Scrutinizer Scrutinizer Coverage

Laravel Env Sync

Keep your .env in sync with your .env.example or vice versa.

It reads the .env.example file and makes suggestions to fill your .env accordingly.

Installation via Composer

Start by requiring the package with composer

composer require jtant/laravel-env-sync

Then, if you use laravel < 5.5, add the Jtant\LaravelEnvSync\EnvSyncServiceProvider::class service provider to your config/app.php file, and that's it

Usage

Sync your envs files

You can populate your .env file from the .env.example by using the php artisan env:sync command.

The command will tell you if there's anything not in sync between your files and will propose values to add into the .env file.

You can launch the command with the option --reverse to fill the .env.example file from the .env file

You can also use --src and --dest to specify which file you want to use. You must use either both flags, or none.

If you use the --no-interaction flag, the command will copy all new keys with their default values.

Check for diff in your envs files

You can check if your .env is missing some variables from your .env.example by using the php artisan env:check command.

The command simply show you which keys are not present in your .env file. This command will return 0 if your files are in sync, and 1 if they are not, so you can use this in a script

Again, you can launch the command with the option --reverse or with --src and --dest.

The command will also dispatch event Jtant\LaravelEnvSync\Events\MissingEnvVars, which will contain the missing env variables, which could be used in automatic deployments. Event is only fired when there are missing env variables.

Show diff between your envs files

You can show a table that compares the content of your env files by using the php artisan env:diff command.

The command will print a table that compares the content of both .env and .env.example files, and will highlight the missing keys.

You can launch the command with the options --src and --dest.

laravel-env-sync's People

Contributors

codegain avatar fatboyxpc avatar julientant avatar mathieutu avatar nunomaduro avatar siebeve avatar sunscreem avatar svenluijten avatar t1sh0o avatar tonysm avatar welcomattic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

laravel-env-sync's Issues

Exclude certain variables from sync

Some variables such as database passwords we don't want to commit in a repository.

Does it make sense to add a possibility to exclude these from the sync?

Would this work with Environment variables outside .env?

Hi! Great package!

We would like to use this as part of a CI/CD deployment pipeline but wonder whether it would work in that instance?
For example, Azure will set environment variables on the "machine" instead of creating a .env file. Would this support that scenario? A quick glance didn't make it seem as though it would

Happy to put the work in to make it do so if not ๐Ÿ‘

Lumen compatibility

Background

Tried to set this repo with Lumen (5.7.6) and it was messing everything up. From composer file

$ composer require jtant/laravel-env-sync
Using version ^1.3 for jtant/laravel-env-sync
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 11 installs, 1 update, 22 removals
  - Removing illuminate/broadcasting (v5.7.11)
  - Removing illuminate/bus (v5.7.11)
  - Removing illuminate/cache (v5.7.11)
  - Removing illuminate/config (v5.7.11)
  - Removing illuminate/console (v5.7.11)
  - Removing illuminate/container (v5.7.11)
  - Removing illuminate/contracts (v5.7.11)
  - Removing illuminate/database (v5.7.11)
  - Removing illuminate/encryption (v5.7.11)
  - Removing illuminate/events (v5.7.11)
  - Removing illuminate/filesystem (v5.7.11)
  - Removing illuminate/hashing (v5.7.11)
  - Removing illuminate/http (v5.7.11)
  - Removing illuminate/log (v5.7.11)
  - Removing illuminate/pagination (v5.7.11)
  - Removing illuminate/pipeline (v5.7.11)
  - Removing illuminate/queue (v5.7.11)
  - Removing illuminate/session (v5.7.11)
  - Removing illuminate/support (v5.7.11)
  - Removing illuminate/translation (v5.7.11)
  - Removing illuminate/validation (v5.7.11)
  - Removing illuminate/view (v5.7.11)
  - Installing symfony/css-selector (v4.1.7): Loading from cache
  - Installing tijsverkoyen/css-to-inline-styles (2.2.1): Loading from cache
  - Installing symfony/routing (v4.1.7): Loading from cache
  - Installing doctrine/lexer (v1.0.1): Loading from cache
  - Installing egulias/email-validator (2.1.6): Loading from cache
  - Installing swiftmailer/swiftmailer (v6.1.3): Loading from cache
  - Installing paragonie/random_compat (v9.99.99): Loading from cache
  - Installing ramsey/uuid (3.8.0): Loading from cache
  - Installing league/flysystem (1.0.49): Loading from cache
  - Installing erusev/parsedown (1.7.1): Loading from cache
  - Updating laravel/framework (v5.7.11 => v5.7.11): Downloading (100%)         
  - Installing jtant/laravel-env-sync (1.3.5): Loading from cache

And php artisan was giving

$ php artisan
PHP Fatal error:  Uncaught ReflectionException: Class path.storage does not exist in ~/vendor/laravel/framework/src/Illuminate/Container/Container.php:779
Stack trace:
#0 ~/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass->__construct('path.storage')
#1 ~/vendor/laravel/framework/src/Illuminate/Container/Container.php(658): Illuminate\Container\Container->build('path.storage')
#2 ~/vendor/laravel/framework/src/Illuminate/Container/Container.php(609): Illuminate\Container\Container->resolve('path.storage', Array)
#3 ~/vendor/laravel/lumen-framework/src/Application.php(260): Illuminate\Container\Container->make('path.storage', Array)
#4 ~/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(121): Laravel\Lumen\Application->make('path.storage', Array)
#5 ~/vendor/laravel/framework/src/Illumi in ~/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 779

In Container.php line 779:
                                                                                                                                                                         
  Uncaught ReflectionException: Class path.storage does not exist in ~/vendor/laravel/framework/src/Illuminate/Container/Container.php:779   
  Stack trace:                                                                                                                                                           
  #0 ~/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass->__construct('path.storage')                    
  #1 ~/vendor/laravel/framework/src/Illuminate/Container/Container.php(658): Illuminate\Container\Container->build('path.storage')           
  #2 ~/vendor/laravel/framework/src/Illuminate/Container/Container.php(609): Illuminate\Container\Container->resolve('path.storage', Array)  
  #3 ~/vendor/laravel/lumen-framework/src/Application.php(260): Illuminate\Container\Container->make('path.storage', Array)                  
  #4 ~/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(121): Laravel\Lumen\Application->make('path.storage', Array)           
  #5 ~/vendor/laravel/framework/src/Illumi                                                                                         

PS

Have you intended to add lumen compatibility ?

Not working if add it to the composer post-install-cmd

I added "php artisan env:sync" to the post-install-cmd in my composer.json and it not working. It asks to set some variable then shows [ERROR] Aborted then asks again and again [ERROR] Aborted.

` [ERROR] Aborted

'SOME_TEST' is not present into your .env file. Its default value is 'test'. Would you like to add it ? [y=yes/n=no/c=change default value] [Copy the default value]:
[y] Copy the default value
[c] Change the default value
[n] Skip

[ERROR] Aborted

'SOME_TEST' is not present into your .env file. Its default value is 'test'. Would you like to add it ? [y=yes/n=no/c=change default value] [Copy the default value]:
[y] Copy the default value
[c] Change the default value
[n] Skip

[ERROR] Aborted

'SOME_TEST' is not present into your .env file. Its default value is 'test'. Would you like to add it ? [y=yes/n=no/c=change default value] [Copy the default value]:
[y] Copy the default value
[c] Change the default value
[n] Skip

[ERROR] Aborted

'SOME_TEST' is not present into your .env file. Its default value is 'test'. Would you like to add it ? [y=yes/n=no/c=change default value] [Copy the default value]:
[y] Copy the default value
[c] Change the default value
[n] Skip

[ERROR] Aborted

'SOME_TEST' is not present into your .env file. Its default value is 'test'. Would you like to add it ? [y=yes/n=no/c=change default value] [Copy the default value]:
[y] Copy the default value
[c] Change the default value
[n] Skip

[ERROR] Aborted`

require php version 5.6+


because 2 reasons, you need require 5.6+

reason 1 laravel-env-sync/src/SyncService.php line 38

2016-09-01 4 18 47
2016-09-01 4 04 07
2016-09-01 4 29 55


reason 2 laravel-env-sync/src/SyncService.php line 35

2016-09-01 4 58 40
2016-09-01 4 18 30
2016-09-01 4 25 25

Unable to install on Laravel 6.18.18 and 5.8.37

Does this still support versions of Laravel prior to 7? It appears to require illuminate/events ^7.0 when I try to install.

Thanks in advance, please let me know if I can provide any other details.

Here is the shell output when trying to install on Laravel 6.18.18

Click to expand!

Shell output

$ composer require jtant/laravel-env-sync
Using version ^4.0 for jtant/laravel-env-sync
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for jtant/laravel-env-sync ^4.0 -> satisfiable by jtant/laravel-env-sync[4.0.0].
    - Conclusion: remove laravel/framework v6.18.18
    - Conclusion: don't install laravel/framework v6.18.18
    - jtant/laravel-env-sync 4.0.0 requires illuminate/events ^7.0 -> satisfiable by illuminate/events[7.x-dev, v7.0.0, v7.0.1, v7.0.2, v7.0.3, v7.0.4, v7.0.5, v7.0.6, v7.0.7, v7.0.8, v7.1.0, v7.1.1, v7.1.2, v7.1.3, v7.10.0, v7.10.1, v7.10.2, v7.10.3, v7.11.0, v7.12.0, v7.13.0, v7.14.0, v7.14.1, v7.15.0, v7.16.0, v7.16.1, v7.17.0, v7.17.1, v7.17.2, v7.2.0, v7.2.1, v7.2.2, v7.3.0, v7.4.0, v7.5.0, v7.5.1, v7.5.2, v7.6.0, v7.6.1, v7.6.2, v7.7.0, v7.7.1, v7.8.0, v7.8.1, v7.9.0, v7.9.1, v7.9.2].
    - don't install illuminate/events 7.x-dev|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.0.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.0.1|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.0.2|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.0.3|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.0.4|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.0.5|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.0.6|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.0.7|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.0.8|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.1.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.1.1|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.1.2|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.1.3|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.10.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.10.1|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.10.2|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.10.3|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.11.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.12.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.13.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.14.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.14.1|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.15.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.16.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.16.1|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.17.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.17.1|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.17.2|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.2.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.2.1|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.2.2|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.3.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.4.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.5.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.5.1|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.5.2|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.6.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.6.1|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.6.2|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.7.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.7.1|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.8.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.8.1|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.9.0|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.9.1|don't install laravel/framework v6.18.18
    - don't install illuminate/events v7.9.2|don't install laravel/framework v6.18.18
    - Installation request for laravel/framework (locked at v6.18.18, required as ^6.2) -> satisfiable by laravel/framework[v6.18.18].


Installation failed, reverting ./composer.json to its original content.
</details>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.