PHPackages                             harmonic/laravel-envcoder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. harmonic/laravel-envcoder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

harmonic/laravel-envcoder
=========================

:description

v1.0.9(4y ago)414.1k7MITPHPCI failing

Since Apr 21Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Harmonic/laravel-envcoder)[ Packagist](https://packagist.org/packages/harmonic/laravel-envcoder)[ Docs](https://github.com/harmonic/laravel-envcoder)[ RSS](/packages/harmonic-laravel-envcoder/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (6)Dependencies (6)Versions (15)Used By (0)

Laravel Envcoder
================

[](#laravel-envcoder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/990317f283836ce6f09cfd10176b7635be0aef55463057efd2d63de0b8cdb71e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6861726d6f6e69632f6c61726176656c2d656e76636f6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/harmonic/laravel-envcoder)[![Total Downloads](https://camo.githubusercontent.com/3092a02b575493b3d80877bb538897dec3cf36e84577fd1c7decb813210a9ac7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6861726d6f6e69632f6c61726176656c2d656e76636f6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/harmonic/laravel-envcoder)[![Build Status](https://camo.githubusercontent.com/c2c1c9017577aa2d3d1ae83e7b0eb9e39203b5fb65b11a11d7eb1654b0de2e45/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6861726d6f6e69632f6c61726176656c2d656e76636f6465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/harmonic/laravel-envcoder)[![StyleCI](https://camo.githubusercontent.com/699fedc0bb01ea0d1b4d01fb2ecf084258de0afc94cdb05089bb2b264bb4acdb/68747470733a2f2f7374796c6563692e696f2f7265706f732f3138323534313238372f736869656c64)](https://styleci.io/repos/182541287)

Encrypts your Laravel .env so that it can be securely stored in source control and decrypted via a password.

It was written to quickly and easily share .env variables within source control instead of having to manually pass around variables or look them up in various 3rd party services.

[![Envcoder-Demo](https://user-images.githubusercontent.com/324026/57817894-3942ab80-77b4-11e9-8cbd-24ee3ae17eab.gif)](https://user-images.githubusercontent.com/324026/57817894-3942ab80-77b4-11e9-8cbd-24ee3ae17eab.gif)

Some highlights of the package include:

- Commit an encrypted version of your .env into source control to share with your team
- Written to be used in various automated deployment processes (password can be stored locally, conflict resolution)
- Can be configured to overwrite, merge, or interactively decide how to deal with merge conflicts within your .env
- Does not require any changes to your project to retrieve .env variables
- Simply edit your .env files as normal (and encrypt them when you are ready to share)
- Compare your encrypted .env with the current one and see what's different

Installation
------------

[](#installation)

Via Composer

```
$ composer require harmonic/laravel-envcoder --dev
```

Publish the config file (optional)

```
php artisan vendor:publish --provider="harmonic\LaravelEnvcoder"
```

Configuration
-------------

[](#configuration)

After publishing the config you can change the default behaviour for environment variable conflict resolution in **config/envcoder.php**.

- 'merge' =&gt; Will merge changes in both files, and overwrite duplicates with what is in .env.enc (default)
- 'prompt' =&gt; Will prompt you for each value that has a different value in .env.enc vs .env or is not in both files
- 'overwrite' =&gt; Will completely overwrite your .env with what is in the encrypted version
- 'ignore' =&gt; Will ignore any changes in your encrypted .env (ie. will not decrypt)

See config/envcoder.php for more details.

Usage
-----

[](#usage)

### Encypting your .env

[](#encypting-your-env)

From your project root simply run:

```
php artisan env:encrypt
```

You will be prompted for a password, if you prefer to enter it from the command line you can use

```
php artisan env:encrypt --password=password
```

(replace password with your password)

#### Encypting another .env file

[](#encypting-another-env-file)

If you have multiple .env files you can add an option (--s or --source) to the encrypt command to tell Envcoder to encrypt that file instead. Envcoder will create an encrypted file with the same name and .enc appended.

```
php artisan env:encrypt -s .env.testing
```

### Decrypting your .env

[](#decrypting-your-env)

From your project root simply run:

```
php artisan env:decrypt
```

You will be prompted for a password, if you prefer to enter it from the command line you can use

```
php artisan env:decrypt --password=password
```

(replace the second password with your password)

#### Encypting another .env file

[](#encypting-another-env-file-1)

If you have encrypted an .env file with a different name (such as .env.testing) you can add an option (--s or --source) to the decrypt command to tell Envcoder to decrypt that file instead.

```
php artisan env:decrypt --source .env.testing.enc
```

This will produce a .env.testing file.

### Compare .env.enc with .env (Diff)

[](#compare-envenc-with-env-diff)

You can review any changes between your current .env and the encrypted one:

```
php artisan env:compare --password=password
```

(replace the second password with your password)

### Include password in your .env file

[](#include-password-in-your-env-file)

You can add a variable to your .env file with the variable ENV\_PASSWORD. This will be removed from the encrypted version but will allow simple encoding/decoding in development with no need for password. Simply add to your .env:

```
ENV_PASSWORD=passwordHere

```

(replace passwordHere with your password)

This way you will not be prompted for a password each time you encrypt/decrypt the .env file.

### Some usage suggestions

[](#some-usage-suggestions)

You may wish to have your production deployment script delete the .env.enc file from your server each time you deploy.

If you include the password in your .env file for local development you could add the env:decrypt command to your composer post-install section to automatically updte your .env file each time you do a composer install, eg.

```
"scripts": {
	"post-install-cmd": [
		"@php artisan env:decrypt"
	]
}
```

Change log
----------

[](#change-log)

Please see the [changelog](changelog.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ phpunit
```

Contributing
------------

[](#contributing)

Please see [contributing.md](contributing.md) for details and a todolist.

Security
--------

[](#security)

We have selected the [defuse\\php-encryption](https://github.com/defuse/php-encryption) package to handle the encryption and decryption of the .env file due to its ease of use and [security](https://github.com/defuse/php-encryption/blob/master/docs/CryptoDetails.md). With that said, storing an encrypted .env file in your source control is less secure than not storing it at all. We believe only marginally, but it's up to you to weigh up the security vs. convience and make a decision for your project.

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Craig Harman](https://github.com/harmonic)
- [All Contributors](../../contributors)

License
-------

[](#license)

MIT. Please see the [license file](license.md) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~86 days

Recently: every ~156 days

Total

10

Last Release

1801d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8861aca590339e178dcfe71ffefc138b28d3a21d0a6f98a9f3f498940382f512?d=identicon)[craigharman](/maintainers/craigharman)

---

Top Contributors

[![craigharman](https://avatars.githubusercontent.com/u/324026?v=4)](https://github.com/craigharman "craigharman (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![mcoypaco](https://avatars.githubusercontent.com/u/12625713?v=4)](https://github.com/mcoypaco "mcoypaco (2 commits)")[![ArjunKishore](https://avatars.githubusercontent.com/u/366087?v=4)](https://github.com/ArjunKishore "ArjunKishore (1 commits)")

---

Tags

environmentenvironment-variableslaravellaravelenvironmentenvlaravel-envcoder

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/harmonic-laravel-envcoder/health.svg)

```
[![Health](https://phpackages.com/badges/harmonic-laravel-envcoder/health.svg)](https://phpackages.com/packages/harmonic-laravel-envcoder)
```

###  Alternatives

[msztorc/laravel-env

Laravel env helper commands

7855.4k](/packages/msztorc-laravel-env)[imliam/laravel-env-set-command

Set a .env file variable from the command line

118352.4k10](/packages/imliam-laravel-env-set-command)[encodia/laravel-health-env-vars

Custom check for Spatie's Laravel Health - Ensure every .env variable you need has been set

20143.5k](/packages/encodia-laravel-health-env-vars)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
