PHPackages                             kingfisherdirect/magento2-env-modules - 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. kingfisherdirect/magento2-env-modules

ActiveMagento2-module[Utility &amp; Helpers](/categories/utility)

kingfisherdirect/magento2-env-modules
=====================================

Magento 2 Patch to allow module definition in env.php

v0.1.1(2y ago)09MIT

Since Apr 4Pushed 2y ago1 watchersCompare

[ Source](https://github.com/kingfisherdirect/magento2-env-modules)[ Packagist](https://packagist.org/packages/kingfisherdirect/magento2-env-modules)[ RSS](/packages/kingfisherdirect-magento2-env-modules/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

Magento 2 env.php Modules
=========================

[](#magento-2-envphp-modules)

> Patch prevents Magento from duplicating `env.php` defined modules in `config.php` makint it easier to manage module status per environment

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

[](#installation)

Caution

This is not yet fully tested under every circumstances. It works for me.

### Install patch source files

[](#install-patch-source-files)

```
composer require kingfisherdirect/magento2-env-modules
```

### Apply patch

[](#apply-patch)

Install composer patches plugin, if you don't have it already.

```
composer require cweagans/composer-patches
```

Note

Details about applying patches can be found on [Magento documentation](https://experienceleague.adobe.com/en/docs/commerce-operations/upgrade-guide/patches/apply).

In the `composer.json` under `extra.patches` add following

```
"magento/magento2-base": {
    "Skip config.php modules if defined in env.php": "vendor/kingfisherdirect/magento2-env-modules/magento2_setup_install.patch"
}

```

Now run `composer install` which will do the patching.
For git users, after successfull installation you should have observe an untracked file in `git status` (`src/setup/src/Magento/Setup/Model/Installer.php`). This file should be commited.

Problem and solution
--------------------

[](#problem-and-solution)

Pretty much explained in following discussions:

- [magento/magento2#38016](https://github.com/magento/magento2/issues/38016)
-

Magento installation saves module status in `config.php` file that should be tracked in git repository. This file is overwritten every time `bin/magento setup:upgrade` is run. Whether module status changed, new module is installed everything is overwritten in `config.php`.

By default Magento also reads `env.php` file for module statuses. However, because of mentioned overwrites to `config.php`, it's not convinient to use `env.php`.

**This module amends the default magento behaviour by excluding modules from beeing written to `config.php` if they're already in `env.php`.**

Important

Module status can be still changed in by `module:enable` or `module:disable` which will write to `config.php`. In cases when module is defined in both `config.php` and `env.php`, status from latter file will be considered.

Example usage scenarious
------------------------

[](#example-usage-scenarious)

Since composer allows to define `require` and `require-dev` packages, dev tools can be added to `require-dev` and only manually enabled through `env.php`. On production `require-dev` packages doesn't have to be installed, therefore nothing should be in `config.php`.

On the other hand modules may be in `require` making it always installed. Because of modules `registration.php` file, it's automatically loaded and status will (and should) be written to `config.php`. Each environment may then use `env.php` to disable module.

Why not a PR to magento/magento2
--------------------------------

[](#why-not-a-pr-to-magentomagento2)

I don't believe this is ready to be shipped in Magento by default.

This patch makes `module:enable` and `module:disable` ineffective for `env.php` defined modules. I needed a solution that works, not neccessary handles every scenario.

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

774d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/13ef32eef650c9bddea30c304036ba5bf091f051be75c05e0abb3aad6628a7e1?d=identicon)[lumnn](/maintainers/lumnn)

---

Top Contributors

[![lumnn](https://avatars.githubusercontent.com/u/2505114?v=4)](https://github.com/lumnn "lumnn (5 commits)")

### Embed Badge

![Health badge](/badges/kingfisherdirect-magento2-env-modules/health.svg)

```
[![Health](https://phpackages.com/badges/kingfisherdirect-magento2-env-modules/health.svg)](https://phpackages.com/packages/kingfisherdirect-magento2-env-modules)
```

###  Alternatives

[danielstjules/stringy

A string manipulation library with multibyte support

2.4k26.0M191](/packages/danielstjules-stringy)[php-stubs/woocommerce-stubs

WooCommerce function and class declaration stubs for static analysis.

942.9M66](/packages/php-stubs-woocommerce-stubs)[kisma/kisma

PHP Utility Belt

178.5k8](/packages/kisma-kisma)

PHPackages © 2026

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