kingfisherdirect/magento2-env-modules 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kingfisherdirect/magento2-env-modules

最新稳定版本:v0.1.1

Composer 安装命令:

composer require kingfisherdirect/magento2-env-modules

包简介

Magento 2 Patch to allow module definition in env.php

README 文档

README

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

Installation

Caution

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

Install patch source files

composer require kingfisherdirect/magento2-env-modules

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.

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

Pretty much explained in following discussions:

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

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

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.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-04