montikids / magento-cli-util
基于Symfony的CLI工具,适用于Magento开发者
Requires
- php: ^8.0||^8.1||^8.2||8.3
- ext-mysqli: *
- ext-sodium: *
- n98/magerun2-dist: *
- symfony/console: >4.0
- symfony/filesystem: ^4||^5.4
- symfony/yaml: >3.3
Requires (Dev)
- friendsofphp/php-cs-fixer: >=2.13
- phpmd/phpmd: @stable
- phpstan/phpstan: >=0.12.81
- squizlabs/php_codesniffer: >=3.4
This package is auto-updated.
Last update: 2024-09-05 12:56:33 UTC
README
不能独立运行:需要Magento 2实例
该工具旨在自动化、简化并将生产环境转换为预发布或开发环境的安全性提高。开发者可以手动使用,或作为部署流程的一部分来配置预发布环境。
它允许描述在数据库中清理数据的场景,这样你就可以确保没有忘记做重要的事情,比如禁用本地集成(可能会造成混乱)或匿名化客户电子邮件(可能会导致意外发送电子邮件)等等。
该工具基于Symfony Console,因此您必须已经熟悉它。它易于使用和扩展。
功能
- 使用YAML配置来描述数据清理场景
- 在Magento表中匿名化敏感客户数据
- 电子邮件
- 姓名
- 地址
- 等等。
- 在
core_config_data
表中替换或删除Magento商店配置值- API集成密钥
- 跟踪服务设置
- 域名
- 等等。
- 在场景中运行自定义SQL查询
- 在场景中运行指定的N98 Magerun 2工具命令或Magento CLI命令
- 按环境灵活配置
- 使用基本(
base.yml
)配置来描述最常见的部分 - 使用特定环境(
dev.yml
,stage.yml
)配置来描述额外的规则或覆盖基本配置中指定的规则 - 使用本地配置(
local.yml
)来满足您的个人需求:添加、自定义或覆盖在基本和/或环境配置中定义的任何规则
- 使用基本(
- 指定详细程度标志
-v
可以使您获得更详细的信息或错误信息
安装
将以下内容添加到您的composer.json
文件中的repositories
部分,以让composer知道在哪里搜索
{ "type": "git", "url": "https://github.com/montikids/magento-cli-util" }
如果您的Magento是通过composer安装的,您可能会得到类似的内容
"repositories": [ { "type": "composer", "url": "https://repo.magento.com/", "canonical": false }, { "type": "git", "url": "https://github.com/montikids/magento-cli-util" } ],
然后运行composer update以更新composer.lock
文件并强制composer发现新的存储库
composer update
现在您可以像通常一样要求包
composer require --dev montikids/magento-cli-util:@dev
安装后,您必须配置环境。
用法/命令
安装后,该工具作为composer二进制文件可用:
vendor/bin/mk-cli-util
列出命令
查看所有当前可用的命令
vendor/bin/mk-cli-util list
可用的命令列表
# Set the util environment type. Different environments use different config files. vendor/bin/mk-cli-util configure:env <env> # Check configuration files are valid vendor/bin/mk-cli-util configure:verify <env> (optional) # Anonymize sensitive data in the Magento database vendor/bin/mk-cli-util db:anonymize # Update "core_config_data" Magento DB table with the config file values vendor/bin/mk-cli-util db:apply-config
配置环境
描述
在第一次运行之前,您必须设置将要使用的环境类型。如果没有它,出于安全原因,您不能运行其他util命令。
可用环境
dev
- 用于本地开发环境stage
- 用于预发布环境
语法
vendor/bin/mk-cli-util configure:env <env>
示例
正常使用
vendor/bin/mk-cli-util configure:env dev
更详细的输出
vendor/bin/mk-cli-util configure:env dev -v
它做什么
- 将指定的环境类型设置为Magento的env配置(
app/etc/env.php
)
'mk_cli_util' => [ 'environment' => 'dev' ]
- 在您的存储库根目录中创建
mk-cli-util
文件夹(如果不存在的话) - 复制配置示例文件夹
- 正在初始化指定环境的配置(仅当它们尚不存在时!)。因此,理论上,你已经准备好开始了。 但是,请务必根据您的需求调整配置!
- 在文件夹内添加一个
.gitignore
文件以排除本地配置文件
建议将
mk-cli-util
文件夹添加到git中,以便在团队间共享配置,并在新功能创建需要清理的点时轻松调整规则。
验证环境配置文件
描述
您始终可以检查您的配置文件是否有效。在依赖于安全使用的自动化部署中,这一点非常重要,您绝对不希望不小心错过数据清理和匿名化这一步。
如果发生任何失败,此命令将返回非零退出代码。如果您在git中配置了管道,只需将此命令的执行添加到管道中,并在将其合并到master/develop之前了解配置的语法错误。通常,如果发生任何错误,管道就会失败。
否则,您需要在部署时验证配置,并且当检查失败时,可能需要整个部署失败。根据您的部署流程,您可能需要跟踪此命令的退出代码,并在退出代码为非零值时明确停止部署流程。
语法
vendor/bin/mk-cli-util configure:verify <env>
示例
检查当前配置环境的文件
vendor/bin/mk-cli-util configure:verify
检查另一个环境的文件
vendor/bin/mk-cli-util configure:verify dev
它做什么
- 它将逐一尝试加载和解析以下配置
- 基本(
base.yml
) - 环境(
dev.yml
或stage.yml
) - 本地(
local.yml
) - 合并(基础 + 环境 + 本地)
- 基本(
- 配置文件将进行两种操作的检查:设置存储配置值和数据库表匿名化
- 如果配置不存在,则跳过非必需的配置,例如本地配置
匿名化数据库数据
描述
运行此命令开始根据配置中指定的场景在Magento数据库中执行数据匿名化处理。
配置路径
mk-cli-util/config/anonymize/base.yml
– 必需的,包含主要和最常见的规则集mk-cli-util/config/anonymize/{{env_name}}.yml
– 可选的,配置名称取决于配置的环境,包含特定于环境的规则mk-cli-util/config/anonymize/local.yml
– 可选的,包含仅针对您的特定规则,不应放在VCS中
语法
vendor/bin/mk-cli-util db:anonymize
示例
正常使用
vendor/bin/mk-cli-util db:anonymize
为了更详细的信息(例如,执行的SQL查询、受影响的行数等)
vendor/bin/mk-cli-util db:anonymize -v
它做什么
- 读取
app/etc/env.php
文件以获取Magento表前缀和默认连接设置 - 根据配置中指定的每个表单独指定的规则匿名化指定的表
- 根据配置中相应部分运行自定义SQL查询
- 根据配置中相应部分运行N98 Magerun 2工具
应用商店配置值
描述
运行此命令开始根据配置中指定的场景应用商店配置值(core_config_data
表)。
配置路径
mk-cli-util/config/store-config/base.yml
– 必需的,包含主要和最常见的规则集mk-cli-util/config/store-config/{{env_name}}.yml
– 可选的,配置名称取决于配置的环境,包含特定于环境的规则mk-cli-util/config/store-config/local.yml
– 可选的,包含仅针对您的特定规则,不应放在VCS中
语法
vendor/bin/mk-cli-util db:apply-config
示例
正常使用
vendor/bin/mk-cli-util db:apply-config
为了更详细的信息(例如,执行的SQL查询、受影响的行数等)
vendor/bin/mk-cli-util db:apply-config -v
它做什么
- 读取
app/etc/env.php
文件以获取Magento表前缀和默认连接设置 - 根据配置的相应部分更新
core_config_data
表内容 - 根据配置中相应部分运行自定义SQL查询
- 根据配置中相应部分运行N98 Magerun 2工具
配置构建参考
所有配置都是YAML文件。配置以允许从基本配置继承并在最具体的配置中覆盖值的方式合并。如果您想使用YAML变量(又称锚点)的话。
配置类型
基本
此配置是必需的,在环境配置过程中自动创建。
它包含主要和最常见的规则集。
建议将其放在版本控制系统中。
环境特定
这些配置是可选的。在环境配置过程中自动创建具有相应名称的配置,但如果不使用它,则不能删除。在这种情况下使用基本配置。
这些配置用于指定特定于环境的某些规则。它们继承基本配置。`dev.yml`配置旨在在开发团队本地使用。`stage.yml`配置旨在在预发布或部署后使用。
建议将其放在版本控制系统中。
本地
此配置是可选的,如果您需要比基本和环境配置更具体的配置,则可以使用它。每个开发人员机器或预发布实例都可以有其副本。
它继承两者:基本配置和环境配置(如果有)。如果没有本地配置,则使用基本和环境配置。
应从版本控制系统中排除
配置合并逻辑
优先级
- 本地
- 环境特定
- 基本
例如,本地配置是最高优先级的。
合并规则
- 优先级较低的配置会继承优先级较高的配置
- 如果在多个配置中指定了相同的路径,则使用优先级较高的配置中的值
匿名化配置
包含对Magento表数据清理的规则。
路径
基本配置
mk-cli-util/config/anonymize/base.yml
环境特定配置
mk-cli-util/config/anonymize/dev.yml
mk-cli-util/config/anonymize/stage.yml
本地配置
-
mk-cli-util/config/anonymize/local.yml
- 部分
- tables
- 必需
tables: {{table_name}} {{field_name}} value: {{option_value}} field_to_concat: {{option_value}} postfix: {{option_value}} is_password: {{option_value}} concat_field_name: {{option_value}} {{field_name}}: null
- 包含表名及其规则,描述了哪些列应进行处理以及如何处理
- 结构如下
{{table_name}}
– 是没有前缀(如果有)的Magento数据库中有效的表名
{{field_name}}
– 是表的有效的字段名将整个字段设置为
null
以跳过匿名化(在您在更具体的配置中覆盖值时很有意义){{option_value}}
– 取决于选项- value
- 是字符串或null,默认值是
''
- 描述要替换的列的主要值或前缀,如果将其与另一个字段值、后缀或两者结合使用
field_to_concat
- 是同一表中的有效表字段名(字符串)或null,默认值是
null
- 指定的字段的值将附加到
value
- 如果设置为null,则不附加字段值
- 是同一表中的有效表字段名(字符串)或null,默认值是
postfix
- 是字符串或null,默认值是
null
- 一些静态字符串,您希望将其放在
value
或field_to_concat
之后(取决于选项值) - 如果设置为null,则不添加后缀
- 是字符串或null,默认值是
is_password
- 是布尔值,默认值是
false
- 目前,您只能在
customer_entity
表中使用此选项 - 当选项设置为
true
时,`value`将按Magento加密客户密码的方式加密,因此您可以使用指定的密码登录客户帐户 - 当选项设置为
true
时,将忽略field_to_concat
和postfix
- 是布尔值,默认值是
concat_field_name
- 是布尔值,默认值是
false
- 当设置为
true
时,将{{field_name}}
作为静态字符串连接到结果值的末尾 - 字段名称连接在
postfix
、field_to_concat
或value
之后,具体取决于它们的设置 - 我不知道为什么有人需要它,但就是这样
- 是布尔值,默认值是
- 任何字段选项都可以省略,然后使用默认值
-
sql_query
- 可选
- 是一个键值对集合,包含你希望在处理完
tables
部分后运行的定制SQL查询 - 必需
sql_query: {{alias}}: {{query}} {{alias}}: null
{{alias}}
- 是一个字符串
- 必须是有效的YAML键(尽量不使用任何特殊字符或空格)
- 代表查询的有意义名称
{{query}}
- 是一个有效的SQL查询(字符串)或null
- 将被“原样”运行,这意味着如果你使用它,你必须指定表前缀
- 尾部分号是可选的
null
值表示你想要跳过运行此查询(当在更具体的配置中覆盖值时很有意义)
- 你可以将整个部分设置为null(
sql_query: null
),如果你不想执行任何查询(当在更具体的配置中覆盖部分时很有意义)
-
n98_magerun2_command
-
可选
-
是一个键值对集合,包含你希望在处理完
tables
部分后运行的N98 Magerun 2工具命令 -
必需
n98_magerun2_command: {{alias}}: {{command}} {{alias}}: null
{{alias}}
- 是一个字符串
- 必须是有效的YAML键(尽量不使用任何特殊字符或空格)
- 代表命令的有意义名称
{{command}}
- 是一个有效的N98 Magerun 2工具命令(字符串)或null
- 将被“原样”运行,这意味着如果你有一些命令参数,你必须指定所有参数
null
值表示你想要跳过运行此命令(当在更具体的配置中覆盖值时很有意义)
- 你可以将整个部分设置为null(
n98_magerun2_command: null
),如果你不想执行任何命令(当在更具体的配置中覆盖部分时很有意义)
示例
以下示例演示了编写部分的一般方法以及如何使用YAML锚(变量)。有关更详细的示例,请参阅存储库中对应的文件夹the corresponding folder
variables: - &mail_domain '@trash-mail.com' - &customer_password 'Password123' - &customer_phone '1234 5678' - &customer_fax '1234 5678' - &customer_street ' test avenue' - &ip '0.0.0.0' tables: customer_entity: firstname: value: 'firstname_' field_to_concat: 'entity_id' lastname: value: 'firstname_' field_to_concat: 'entity_id' email: value: 'dev_' field_to_concat: 'entity_id' postfix: *mail_domain password_hash: value: *customer_password is_password: true customer_address_entity: firstname: value: 'firstname_' field_to_concat: 'entity_id' lastname: value: 'lastname_' field_to_concat: 'entity_id' street: value: *customer_street field_to_concat: 'entity_id' city: value: 'city_' field_to_concat: 'entity_id' telephone: value: *customer_phone field_to_concat: 'entity_id' fax: value: *customer_fax field_to_concat: 'entity_id' sql_query: truncate_reporting_users: "TRUNCATE reporting_users;" n98_magerun2_command: reindex: 'indexer:reindex'
合并示例
基本配置
variables: - &mail_domain '@trash-mail.com' - &customer_password 'Password123' - &customer_phone '1234 5678' - &customer_fax '1234 5678' - &customer_street ' test avenue' - &ip '0.0.0.0' tables: customer_entity: firstname: value: 'firstname_' field_to_concat: 'entity_id' lastname: value: 'firstname_' field_to_concat: 'entity_id' email: value: 'dev_' field_to_concat: 'entity_id' postfix: *mail_domain password_hash: value: *customer_password is_password: true customer_address_entity: firstname: value: 'firstname_' field_to_concat: 'entity_id' lastname: value: 'lastname_' field_to_concat: 'entity_id' street: value: *customer_street field_to_concat: 'entity_id' city: value: 'city_' field_to_concat: 'entity_id' telephone: value: *customer_phone field_to_concat: 'entity_id' fax: value: *customer_fax field_to_concat: 'entity_id' sql_query: truncate_reporting_users: "TRUNCATE reporting_users;" n98_magerun2_command: reindex: 'indexer:reindex'
特定环境配置
variables: - &customer_password 'my_awesome_password' - &mail_domain '@test.com' tables: customer_entity: firstname: value: 'John' field_to_concat: null email: postfix: *mail_domain password_hash: value: *customer_password lastname: value: 'Doe' sql_query: truncate_queue_message_status: 'TRUNCATE queue_message_status;' clean_queue_message: 'DELETE FROM queue_message;' n98_magerun2_command: generate_urn: 'dev:urn-catalog:generate .idea/misc.xml'
本地配置
variables: - &customer_password '567***$ERFhgdgds!#$@' - &mail_domain '@local.test' tables: customer_entity: firstname: value: 'Sheldon ' field_to_concat: 'entity_id' email: value: '' postfix: *mail_domain password_hash: value: *customer_password lastname: null customer_address_entity: firstname: value: 'Sheldon ' sql_query: truncate_reporting_users: null n98_magerun2_command: reindex: null
结果
tables: customer_entity: firstname: value: 'Sheldon ' field_to_concat: 'entity_id' lastname: value: 'firstname_' field_to_concat: 'entity_id' email: value: '' field_to_concat: 'entity_id' postfix: '@local.test' password_hash: value: '567***$ERFhgdgds!#$@' is_password: true customer_address_entity: firstname: value: 'Sheldon ' field_to_concat: 'entity_id' lastname: value: 'lastname_' field_to_concat: 'entity_id' street: value: ' test avenue' field_to_concat: 'entity_id' city: value: 'city_' field_to_concat: 'entity_id' telephone: value: '1234 5678' field_to_concat: 'entity_id' fax: value: '1234 5678' field_to_concat: 'entity_id' sql_query: truncate_reporting_users: null truncate_queue_message_status: 'TRUNCATE queue_message_status;' clean_queue_message: 'DELETE FROM queue_message;' n98_magerun2_command: reindex: null generate_urn: 'dev:urn-catalog:generate .idea/misc.xml'
商店配置值配置
包含更新core_config_data
Magento表值的规则
语法
vendor/bin/mk-cli-util db:apply-config
路径
基本配置
mk-cli-util/config/store-config/base.yml
环境特定配置mk-cli-util/config/store-config/dev.yml
mk-cli-util/config/store-config/stage.yml
本地配置mk-cli-util/config/store-config/local.yml
本地配置
-
配置
- 部分
- 包含配置路径(表示
core_config_data
表的path
字段)以及它们的规则,描述如何处理它们的值 - 可以为默认范围、任何网站或任何商店指定路径
- 必需
config: {{scope_name}}: {{scope_id}}: {{path}}: {{value}} {{path}}: encrypt: {{non_ecrypted_value}} {{path}}: delete: true {{path}}: skip: true
{{scope_name}}
– 是default
、websites
或stores
{{scope_id}}
– 对于default
范围是0
,对于websites
和stores
是相应的有效(已存在)网站或商店ID{{table_name}}
– 是没有前缀(如果有)的Magento数据库中有效的表名
{{path}}
– 配置值路径,即它正好在core_config_data
表的path
字段中指定的路径{{value}}
- 是一个字符串或一个特殊指令(
delete: true
、skip: true
) - 对于布尔值,请使用
'0'
和'1'
而不是相应的false
和true
- 将整数、浮点数等值指定为字符串,例如:
'139'
、'18.35'
等等 加密:{{未加密值}}
- 这是一个特殊指令,以 Magento 的方式加密
{{未加密值}}
- 使用它来设置类型为 隐蔽 的字段,如密码、API 密钥等
{{未加密值}}
– 是一个 字符串,表示原始模式(加密前)中的密码/API 密钥等
- 这是一个特殊指令,以 Magento 的方式加密
删除:true
- 这是一个特殊指令,从表中完全删除指定路径的行
- 当您想强制使用
config.xml
中的默认值或只想取消配置值时,您可能需要它
跳过:true
- 这是一个特殊指令,允许跳过处理路径值(当您在更具体的配置中覆盖值时很有意义)
- 是一个字符串或一个特殊指令(
-
sql_query
- 可选
- 是一个键值对集合,包含你希望在处理完
tables
部分后运行的定制SQL查询 - 必需
sql_query: {{alias}}: {{query}} {{alias}}: null
{{alias}}
- 是一个字符串
- 必须是有效的YAML键(尽量不使用任何特殊字符或空格)
- 代表查询的有意义名称
{{query}}
- 是一个有效的SQL查询(字符串)或null
- 将被“原样”运行,这意味着如果你使用它,你必须指定表前缀
- 尾部分号是可选的
null
值表示你想要跳过运行此查询(当在更具体的配置中覆盖值时很有意义)
- 你可以将整个部分设置为null(
sql_query: null
),如果你不想执行任何查询(当在更具体的配置中覆盖部分时很有意义)
-
n98_magerun2_command
- 可选
- 是一个键值对集合,包含你希望在处理完
tables
部分后运行的N98 Magerun 2工具命令 - 必需
n98_magerun2_command: {{alias}}: {{command}} {{alias}}: null
{{alias}}
- 是一个字符串
- 必须是有效的 YAML 键(尽量不使用任何特殊字符或空格)
- 代表命令的有意义名称
{{command}}
- 是一个有效的N98 Magerun 2工具命令(字符串)或null
- 将被“原样”运行,这意味着如果你有一些命令参数,你必须指定所有参数
null
值表示你想要跳过运行此命令(当在更具体的配置中覆盖值时很有意义)
- 你可以将整个部分设置为null(
n98_magerun2_command: null
),如果你不想执行任何命令(当在更具体的配置中覆盖部分时很有意义)
示例
以下示例演示了编写部分的常规方法。有关更多示例,请参阅存储库中的 相应文件夹。
config: default: 0: ### Security ### admin/security/password_lifetime: '9000' admin/security/session_lifetime: '9000' ### HTTPS ### web/secure/use_in_frontend: delete: true web/secure/use_in_adminhtml: delete: true ### Mail ### system/smtp/disable: '1' system/smtp/host: delete: true system/smtp/port: delete: true stores: 1: general/store_information/name: 'My store name (store-level)' websites: 1: general/store_information/name: 'My store name (website-level)' sql_query: clean_report: 'DELETE FROM reporting_users;' n98_magerun2_command: cache_flush: 'cache:flush'
合并示例
基本配置
config: default: 0: ### Security ### admin/security/password_lifetime: '9000' admin/security/session_lifetime: '9000' ### HTTPS ### web/secure/use_in_frontend: delete: true web/secure/use_in_adminhtml: delete: true ### Mail ### system/smtp/disable: '1' system/smtp/host: delete: true system/smtp/port: delete: true stores: 1: general/store_information/name: 'My store name (store-level)' websites: 1: general/store_information/name: 'My store name (website-level)' sql_query: clean_report: 'DELETE FROM reporting_users;' n98_magerun2_command: cache_flush: 'cache:flush'
特定环境配置
config: default: 0: # Let's mitigate security politics for developers machines admin/security/password_lifetime: '' admin/security/session_lifetime: 31536000 admin/security/password_is_forced: '0' # In case the most developers don't use HTTPS locally web/secure/use_in_frontend: delete: true web/secure/use_in_adminhtml: delete: true # You probably don't want sending data to NewRelic from developers machines newrelicreporting/general/enable: '0' newrelicreporting/cron/enable_cron: '0' newrelicreporting/general/account_id: delete: true newrelicreporting/general/app_id: delete: true newrelicreporting/general/api: delete: true newrelicreporting/general/insights_insert_key: delete: true # Enable some payment methods handy to use on development payment/checkmo/active: '1' sql_query: truncate_wishlist: 'TRUNCATE wishlist;' clean_report: null n98_magerun2_command: show_mode: 'deploy:mode:show'
本地配置
config: default: 0: web/unsecure/base_url: 'http://magento.test/' web/secure/base_url: 'https://magento.test/' admin/url/custom: 'https://magento.test/' web/secure/use_in_frontend: '1' web/secure/use_in_adminhtml: '1' stores: 1: general/store_information/name: skip: true sql_query: null
结果
config: default: 0: admin/security/password_lifetime: '' admin/security/session_lifetime: 31536000 admin/security/password_is_forced: '0' web/unsecure/base_url: 'http://magento.test/' web/secure/base_url: 'https://magento.test/' admin/url/custom: 'https://magento.test/' web/secure/use_in_frontend: '1' web/secure/use_in_adminhtml: '1' newrelicreporting/general/enable: '0' newrelicreporting/cron/enable_cron: '0' newrelicreporting/general/account_id: delete: true newrelicreporting/general/app_id: delete: true newrelicreporting/general/api: delete: true newrelicreporting/general/insights_insert_key: delete: true payment/checkmo/active: '1' system/smtp/disable: '1' system/smtp/host: delete: true system/smtp/port: delete: true stores: 1: general/store_information/name: skip: true websites: 1: general/store_information/name: 'My store name (website-level)' sql_query: null n98_magerun2_command: cache_flush: 'cache:flush' show_mode: 'deploy:mode:show'
本地开发和测试
由于该包不能独立存在(没有 Magento 安装),因此本地开发相当具有挑战性。
强烈建议您使用单独文件夹中的 Magento 项目的副本。这可以防止您不断修改/撤销
composer.json
和composer.lock
文件,节省您大量时间和精力。这是因为本地开发需要添加指向本地目录的定制存储库
准备
有一个技巧可以让 composer 加载包的本地版本而不是从存储库中下载。将以下内容添加到您的 Magento 安装的 composer.json
中的 repositories
部分。
{ "type": "path", "url": "../magento-cli-util", "options": { "symlink": false } }
其中
"type": "path"
– 告诉 composer 您想加载本地目录"url": "../magento-cli-util"
– 相对或绝对路径到包含包的目录"symlink": false
– 告诉 composer 复制/镜像文件而不是创建符号链接
符号链接可能看起来更方便,但您可能在使用相对路径时遇到一些问题
如果您已经安装了该包
遗憾的是,在这种情况下,我找到的唯一解决方案是删除 composer.lock
文件。没有这个,存储库 URL 不会更新,您将继续从存储库接收包而不是指定的本地路径。
rm -f composer.lock
删除您拥有的包版本并清理 composer 缓存
rm -rf vendor/montikids/magento-cli-util && rm -rf vendor/bin/mk-cli-util && composer clear-cache
运行包安装并去厨房冲一杯咖啡
composer install
如果是首次安装
像往常一样要求包
composer require --dev montikids/magento-cli-util:@dev
您应该看到类似以下内容(请注意单词 mirroring
)
- Installing montikids/magento-cli-util (dev-1.0.0): Mirroring from ../magento-cli-util
开发
- 在本地文件夹中更改您需要的包
- 从 Magento 项目的 vendor 中删除过时的版本,清理缓存并运行缺失包的安装
rm -rf vendor/montikids/magento-cli-util rm -rf vendor/bin/mk-cli-util composer clear-cache composer install
我更喜欢以单个命令运行它,当您需要经常测试您的更改时,这要方便得多
rm -rf vendor/montikids/magento-cli-util && rm -rf vendor/bin/mk-cli-util && composer clear-cache && composer install
- 收益!
如果您修改了包的
composer.json
(例如,依赖项之一的版本),您将不得不更新 Magento 项目的composer.lock
composer update如果不起作用,请删除
composer.lock
并运行composer install