PHPackages                             ibrostudio/laravel-multenv - 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. ibrostudio/laravel-multenv

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

ibrostudio/laravel-multenv
==========================

Manage multiple Laravel env files

1.1.0(2y ago)012MITPHPPHP ^8.1

Since Jun 1Pushed 2y ago1 watchersCompare

[ Source](https://github.com/iBroStudio/laravel-multenv)[ Packagist](https://packagist.org/packages/ibrostudio/laravel-multenv)[ Docs](https://github.com/ibrostudio/laravel-multenv)[ RSS](/packages/ibrostudio-laravel-multenv/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (9)Versions (5)Used By (0)

Laravel Multenv
===============

[](#laravel-multenv)

Manage multiple .env files in Laravel with automatic encryption to embed and share your .env files in your repository.

- [Installation](#installation)
- [Basic usage](#basic-usage)
- [Encryption](#encryption)
- [Automatic encryption](#automatic-encryption)
- [Different env files per GIT branches](#different-env-files-per-git-branches)

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

[](#installation)

You can install the package via composer:

```
composer require ibrostudio/laravel-multenv
```

Publish the config file with:

```
php artisan vendor:publish --tag="multenv-config"
```

This is the contents of the published config file:

```
return [
    '.env.primary' => ['encrypt' => true],
    '.env.custom' => ['encrypt' => false],
];
```

You define which .env files you want to manage:

- a primary .env file, with all variables
- then, you can add one (or more) entries to override variables

Basic usage
-----------

[](#basic-usage)

At the root of your project, create all files defined in the config and populate them with variables.

Add them to your .gitignore:

```
.env.primary
.env.custom

```

or

```
.env*

```

Then run:

```
php artisan multenv:merge
```

It generates the final .env file, merging variables from all configured .env files.

Encryption
----------

[](#encryption)

You can encrypt some .env files to embed them securely in your repo.

**Generate encryption key**

```
php artisan multenv:key
```

Add it to your .gitignore:

```
.multenv

```

**Don't commit your .multenv key in your repo, it is a security risk.**

If you work with people on the repo, share manually the key, IT HAS TO BE SAME for everyone.

**Configure the files to encrypt**

In config/multenv.php, define each file to encrypt with the setting to true

```
'.env.primary' => ['encrypt' => true]
```

**Encrypt**

```
php artisan multenv:encrypt
```

If you use **.env** in your .gitignore, add after:

```
.env*
!.env.*.encrypted

```

**Decrypt**

```
php artisan multenv:decrypt
```

Automatic encryption
--------------------

[](#automatic-encryption)

You can define some git hooks to automate the processes:

**1. Merge, encrypt and commit**

Create (or modify) a file called ***pre-push*** in .git/hooks and add in it:

```
#!/bin/sh

echo "---- PRE PUSH ----"
php artisan multenv:encrypt
git add .env.*.encrypted
git commit -m 'Auto embed encrypted env files'
echo "--- PRE PUSH END ---"
```

Make it executable:

```
chmod +x pre-push
```

**2. Decrypt and merge**

Create (or modify) a file called ***post-merge*** in .git/hooks and add in it:

```
#!/bin/sh

echo "---- POST MERGE ----"
php artisan multenv:decrypt
php artisan multenv:merge
echo "--- POST MERGE END ---"
```

Make it executable:

```
chmod +x post-merge
```

Different env files per GIT branches
------------------------------------

[](#different-env-files-per-git-branches)

Modify the configuration as following, adding a pattern entry:

```
return [
    '.env.primary' => ['encrypt' => true, 'pattern' => 'branch-*'],
    '.env.custom' => ['encrypt' => false],
];
```

Then, at the root of your project, create env branches files with names based on the pattern.

Example : .env.branch-main

Populate them with variables and use methods like described previously.

**If you want/need to keep safe between branches, use a different multenv key for each branch.**

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 69.2% of commits — single point of failure

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 ~3 days

Total

4

Last Release

1070d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a456dae716df4be38cb7d5f02ca522a02ec37eda586ab0cae0f504516b7c1ef?d=identicon)[iBroStudio](/maintainers/iBroStudio)

---

Top Contributors

[![Yann-iBroStudio](https://avatars.githubusercontent.com/u/2676572?v=4)](https://github.com/Yann-iBroStudio "Yann-iBroStudio (9 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

laravelenviBroStudio

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ibrostudio-laravel-multenv/health.svg)

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

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