magento-trigger-test / magento-composer-installer
Magento 模块的 Composer 安装器
Requires
- composer-plugin-api: ^1.1 || ^2.0
- composer/composer: ^1.9 || ^2.0
Requires (Dev)
- firegento/phpcs: ~1.1.0
- mikey179/vfsstream: *
- phpunit/phpunit: *
- phpunit/phpunit-mock-objects: dev-master
- squizlabs/php_codesniffer: 1.4.7
- symfony/process: *
This package is auto-updated.
Last update: 2024-09-18 23:41:40 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 选项。它仅用于保留向后兼容性。