staempfli/magento2-builder-tool

此包已被废弃,不再维护。未建议替换包。

Staempfli AG Magento2 Builder Tool

3.0.0 2019-04-15 07:02 UTC

This package is auto-updated.

Last update: 2020-09-16 11:57:15 UTC


README

Project Status: Abandoned – Initial development has started, but there has not yet been a stable, usable release; the project has been abandoned and the author(s) do not intend on continuing development. Codacy Badge Maintainability

自动构建 Magento2 项目并从远程服务器同步数据的工具。

本地环境

  • 设置本地环境(数据库、配置、服务器)
  • 安装项目的真实数据(从服务器同步)

CI / 构建环境

  • 准备数据库和配置以执行测试。
  • 构建并传输准备部署到服务器的工件。

安装

composer require "staempfli/magento2-builder-tool":"~2.0"

演示

Magento2 Builder Playlist

简介

magento2-builder-tool 是一个通过执行一条命令来设置 Magento2 项目本地环境的工具。无需 Docker 或 Vagrant,但也可以在这些虚拟化设置中使用。数据库、Apache/Nginx 配置以及所有其他内容都为每个项目自动创建。您甚至可以使用 sync 模式将服务器数据复制到本地。

此工具也适用于 CIBuild 环境,以自动化创建工件的过程。

此工具为您做什么

本地环境

1. Create Magento Database
2. Create Integration Test Database
3. Magento Install
4. Sync Data From Server
5. Update core_config_data for your environment
6. setup:upgrade
7. clean cache
8. Setup Apache/Nginx configuration

唯一的手动步骤是编辑您的 /etc/hosts。如果也要自动化此步骤,请参阅 DnsMasq on MAC

CI / 构建环境

- Create DB for integration tests
- Builds and transfer artifact that can be directly deployed on a server

设置

配置文件夹

cp -r <vendor_path>/staempfli/magento2-builder-tool/config.sample/ config
  • 将项目语言和其他配置设置到 config/project.propertiesconfig/mg2-builder/build.properties
  • config/mg2-builder/magento/config.yaml 上设置项目自定义 core_config_data
  • config/mg2-builder/server/config.yaml 上设置项目服务器设置

注意: 您只需要替换 << 之间的参数与您的对应值。所有其他占位符(如 ${}{{}})将在工具执行期间自动替换

创建日志文件夹

mkdir logs
vim logs/.gitignore
# Ignore everything in this directory
*
# Except this file
!.gitignore

自定义属性

您可以根据需要自定义所有属性

  • config/mg2-builder/build.propertiesconfig/project.properties 中添加的属性具有更高的优先级,并将覆盖默认值
  • 检查此处可以自定义的所有属性

本地环境

用法

  • 列出可用目标

    • bin/mg2-builder -l
  • 项目安装

    • bin/mg2-builder install
  • 从服务器同步数据

    • bin/mg2-builder sync

提示

本地设置

如果您不想反复输入所需的属性,您可以按照以下方式设置默认环境参数

  1. 在项目根目录的上一级创建 _conf 文件夹。

  2. 在该文件夹内添加一个新文件 environment.properties

  3. 在此文件中,您可以按照以下方式指定环境属性

project.environment=<your_environment_type> (usually Local)
database.admin.username=<your_database_admin_user>
environment.server.type=<your_server_type> (apache, nginx or none)
environment.vhosts.dir=<your_preferred_vhost.d_path>

无密码SSH

为了每次跳过输入ssh密码,您可以使用 ssh-copy-id 在服务器上自动设置公私钥。只需执行以下操作

ssh-copy-id user@server-domain

MAC上的DnsMasq

OS X 上,您甚至可以通过使用 dnsmasq 跳过手动编辑 etc/hosts 的步骤。您可以配置它自动加载所有 *.dev*.lo url(*.local 不可用)。

注意:当添加新的 dnsmasq 时,您需要重新加载 dnsmasq守护进程

sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

CI / 构建环境

用法

  • 为集成测试创建数据库和设置

    • bin/mg2-builder tests-setup:install
  • 创建并传输构建工件

    • bin/mg2-builder artifact:transfer [-Dartifact.name, -Duse.server.properties]

自定义脚本

如果您需要额外的脚本以构建项目,您可以在此处添加它们

  • config/mg2-builder/xmlscripts/custom.xml

您还可以定义在构建过程中自动执行的目标。此工具包含 customHooks,可以侦听以调度其他目标。您可以在 config/mg2-builder/project.properties 中设置这些挂钩要执行的目标

vim config/mg2-builder/xmlscripts/custom.xml
before-magento-install = <your-custom-target>
after-sync = <your-custom-target>
after-tests-setup-integration = <your-custom-target>
after-util-db-clean = <your-custom-target>

免责声明

为了使用同步功能,远程服务器上必须可用 n98-magenrun2。最简单的方法是将它作为项目依赖的一部分添加

composer require "n98/magerun2":"^1.4"

如果您以其他方式在服务器上安装 n98-magerun2,请确保相应地配置参数 sync.bin.n98-magerun2

故障排除

在magento 2.2.x版本上设置null配置值

  • 问题PR #15216
  • 解决方案:使用composer直接在项目中应用补丁
"require": {
	"cweagans/composer-patches": "^1.0"
},
"extra": {
	"patches": {
		"magento/module-config": {
			"Make possible to set null values using config:set command": "https://stash.staempfli.com/projects/MAG/repos/magento2-patches/raw/patches/2.2.x/config-set-null-value/version-2.2.0.patch"
		}
	},
	"composer-exit-on-patch-failure": true
}

注意:使用 version-2.2.0.patch 对 magento >=2.2.0 <=2.2.3,使用 version-2.2.4.patch 对 magento >=2.2.4

MySQL服务器已断开连接

  • 问题MySQL 在创建、导入或更新 Magento 数据库时有时会崩溃。

  • 解决方案:在您的 .my.cnf 中添加以下配置

  • 如何重启mysql:杀死MySQL进程,启动MySQL并重试

    1. killall -9 mysqld
    2. mysql.server startmysql.server restart
    3. 重试:mg2-builder install

先决条件

  • PHP >= 7.0.*
  • Mysql >= 5.7.*

变更日志

CHANGELOG.md

开发者

许可证

GNU通用公共许可证,版本3 (GPLv3)

版权

(c) 2017 Staempfli AG