magenxcommerce/magento-composer-installer

Magento模块的Composer安装程序

0.2.1 2021-10-22 05:37 UTC

This package is auto-updated.

Last update: 2024-09-22 12:19:59 UTC


README

这是一个基于Magento Composer Installer仓库的分支,该仓库为Magento 2组件(模块、主题、语言包、库和组件)提供支持。

用法

在组件的composer.json中指定

  • type,Magento 2组件的类型。

  • extra/map,要移动的文件列表及其相对于Magento根目录的路径。

  • extra/chmod,应设置的文件权限列表。

    注意:

    • extra/map仅在组件需要移动到除<Magento根目录>/vendor之外的位置时才需要。否则,省略此部分。
    • extra/chmod仅在您需要为文件设置特定权限时才需要。

支持的组件

以下列表解释了在composer.json中使用type的方法。

Magento模块

"type": "magento2-module"

安装位置:默认供应商目录或定义在extra/map

示例

{
    "name": "magento/module-core",
    "description": "N/A",
    "require": {
        ...
    },
    "type": "magento2-module",
    "extra": {
        "map": [
            [
                "*",
                "Magento/Core"
            ]
        ]
    }
}

最终位置是<magento根目录>/app/code/Magento/Core

Magento主题

"type": "magento2-theme"

安装位置:app/design

示例

{
    "name": "magento/theme-frontend-luma",
    "description": "N/A",
    "require": {
        ...
    },
    "type": "magento2-theme",
    "extra": {
        "map": [
            [
                "*",
                "frontend/Magento/luma"
            ]
        ]
    }
}

最终位置是<magento_root>/app/design/frontend/Magento/luma

Magento语言包

"type": "magento2-language"

安装位置:app/i18n

示例

{
    "name": "magento/language-de_de",
    "description": "German (Germany) language",
    "require": {
        ...
    },
    "type": "magento2-language",
    "extra": {
        "map": [
            [
                "*",
                "Magento/de_DE"
            ]
        ]
    }
}

最终位置是<magento_root>/app/i18n/Magento/de_DE

Magento库

"type": "magento2-library"

支持位于lib/internal中的库,而不是在vendor目录中。

示例

{
    "name": "magento/framework",
    "description": "N/A",
    "require": {
       ...
    },
    "type": "magento2-library",
    "extra": {
        "map": [
            [
                "*",
                "Magento/Framework"
            ]
        ]
    }
}

最终位置是<magento_root>/lib/internal/Magento/Framework

Magento组件

"type": "magento2-component"

安装位置:Magento根目录

示例

{
    "name": "magento/migration-tool",
    "description": "N/A",
    "require": {
        ...
    },
    "type": "magento2-component",
    "extra": {
        "map": [
            [
                "*",
                "dev/tools/Magento/Tools/Migration"
            ]
        ]
    }
}

最终位置是<magento_root>/dev/tools/Magento/Tools/Migration

自动加载

处理所有Magento组件后,<magento_root>/app/etc/vendor_path.php指定了vendor目录的路径。

此信息允许Magento应用程序利用Composer自动加载器利用在vendor目录中安装的任何库。由于vendor目录的路径因特定安装而异,并且取决于Magento Composer安装器的magento_root设置,因此它应该为每个安装生成。

您必须运行composer install来安装新应用的依赖项,或运行composer update来更新现有应用的依赖项。

部署策略

Magneto Composer Installer使用copy部署策略。它根据组件composer.json中的extra/map部分将每个文件或目录从vendor目录复制到指定的位置。

可以使用其他部署策略;然而,我们不保证它们中的任何一种都会工作。

使用extra/chmod

以下示例显示了如何为文件设置特定权限。

示例

{
    "name": "magento/module-sample",
    "description": "N/A",
    "require": {
        ...
    },
    "type": "magento2-module",
    "extra": {
         "chmod": [
            {
                "mask": "0755",
                "path": "bin/magento"
            },
            {
                "mask": "0644",
                "path": "some_dir/file.jpg"
            }
        ]
    }
}

mask是chmod命令的位掩码

path是相对于Magento根文件夹的文件路径

注意

  • extra->magento-root-dir选项不再受支持。它仅用于保留向后兼容性。