定制 monogo/optimize-object-manager 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

monogo/optimize-object-manager

Composer 安装命令:

composer require monogo/optimize-object-manager

包简介

Magento 2 module to optimize Compiled ObjectManager

README 文档

README

Magento 2 module to optimize Compiled ObjectManager.

This module will work only with Magento 2.3.4 and higher

Important

This is experimental functionality, You are using it at your own risk !

Install

Composer

In perfect world, command composer require monogo/optimize-object-manager should do the job.

But in few cases, composer do not recognize patch files.

If you don't see line

  - Applying patches for magento/framework"

run

composer require cweagans/composer-patches

Add in your composer.json

"extra": {
           "composer-exit-on-patch-failure": true,
           "patches": {
               "magento/framework": {
                   "Optimize Magento ObjectManager ConfigLoader: ": "https://raw.githubusercontent.com/MonogoPolska/monogo-m2-optimize-object-manager/master/patches/composer/optimize-config-loader.diff"
               }
           }
       }

Run

composer install

You should see line

  - Applying patches for magento/framework"

if not, go to vendor/magneto and remove framework directory, then re-run

composer install

Magento Setup

  • Run Magento commands

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento setup:static-content:deploy

  • Make sure your that Magento 2 instance is running in Production mode and after installation generated/metadata directory is not empty

Configuration Options

Edit app/etc/env.php

add lines:

    'monogo_autoload_optimization' => [
        'enabled' => 1,
        'allowed_area' => [
            'frontend',
        ],
    ],
  • enabled - 0 or 1
  • allowed_area - Magento 2 area (frontend,adminhtml,crontab,webapi_rest,webapi_soap,...) .

Check

After installation and configuration, you should see new files in generated/metadata , for example:

  • __frontend_global_diff.php
  • __adminhtml_global_diff.php

How it works

When you are using M2 in Production mode and generated/metadata directory is not empty, magento is using Compiled mode in Object Manager.

Generated files contains all classes and are heavy.

In my case it was >8 MB per one area file.

Magento is loading global.php file and after that your area file (for example frontend.php).

This module is calculating diff between global.php and given area, and it is saving new file __[area_code]_global_diff.php

If diff file exists, it is coping loaded global config to given area, and it is patching config with the diff.

The original area file (for example frontend.php) is skipped.

In my case (API call) it improved simple request by 14% of time and 33% of memory used.

monogo/optimize-object-manager 适用场景与选型建议

monogo/optimize-object-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37 次下载、GitHub Stars 达 4, 最近一次更新时间为 2020 年 06 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「optimization」 「magento 2」 「ObjectManager」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 monogo/optimize-object-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 monogo/optimize-object-manager 我们能提供哪些服务?
定制开发 / 二次开发

基于 monogo/optimize-object-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-10