magento2插件製做

magneto2 我的插件(模塊)開發


插件經常使用指令

##原版介紹
  module:disable                           Disables specified modules
  module:enable                            Enables specified modules
  module:status                            Displays status of modules
  module:uninstall                         Uninstalls modules installed by composer
  
## 插件列表
php bin/magento module:status
## 安裝插件
php bin/magento module:enable --clear-static-content <MODULE>
## 卸載插件(installed by composer)
php bin/magento module:uninstall --clear-static-content <MODULE>
## 禁用插件
php bin/magento module:disable --clear-static-content <MODULE>

插件文件結構

插件依賴關係

每一個Magento 模塊都負責一個獨特的功能。實際上,這意味着:

多個模塊不能負責一項功能。php

一個模塊不能負責多種功能。json

必須明確聲明對其餘模塊的模塊依賴性。您還必須聲明對其餘組件的任何依賴關係(例如,主題,語言包或庫)。bash

卸下或禁用模塊不會致使禁用其餘模塊。app

包含硬依賴軟依賴composer

  1. composer require:ui

    app/code/<Vendor>/<Module>/composer.json
    
      "require": {
        "magento/module-catalog": "103.0.*",
        "magento/module-email": "101.0.*",
        "magento/module-media-storage": "100.3.*",
        "magento/module-store": "101.0.*",
        "magento/module-theme": "101.0.*",
        "magento/module-ui": "101.1.*",
        "magento/module-variable": "100.3.*",
        "magento/module-widget": "101.1.*",
        "magento/module-authorization": "100.3.*"
      }
  2. composer suggest or <sequence>插件

    app/code/<Vendor>/<Module>/composer.json
    
      "suggest": {
      "magento/module-graph-ql": "*",
      "magento/module-graph-ql-cache": "*",
      "magento/module-store-graph-ql": "*"
      }
    app/code/<Vendor>/<Module>/etc/module.xml
    
     <module name="Magento_Cms">~~~~
         <sequence>
           <module name="Magento_Store"/>
           <module name="Magento_Theme"/>
           <module name="Magento_Variable"/>
         </sequence>
     </module>
相關文章
相關標籤/搜索