Type
library
Staempfli AG Magento2 Builder Tool
library
GPL-3.0
None
None
None
None
None
Tool to automatically build Magento2 projects and sync data from remote servers.
composer require --dev "staempfli/magento2-builder-tool":"~1.0"
magento2-builder-tool
is a tool to setup local environments for your Magento2 projects by executing one command. No Docker, no Vagrant needed but it is also compatible inside those virtualised setups. Database, Apache/Nginx configuration and everything else are created automatically for each project. You can even use sync
mode to get server data copied locally.
Do you know Laravel Valet? That is quite the same but for Magento2.
This tool is also meant for CI
environments to automate the step of creating the build. You can use it to get your project generated before executing the tests.
What this tool does for you:
1. Create Magento Database
2. Create Integration Test Database
3. Magento Install
4. Sync Data From Server
5. Update core_core_data for your environment
6. setup:upgrade
7. clean cache
8. Setup Apache/Nginx configuration
Only manual step is to edit your /etc/hosts
On OS X
you can even skip the manual step of editing the etc/hosts
by using dnsmasq
. You can configure it to automatically load all *.dev
or *.lo
urls (*.local
does not work).
NOTE: When adding a new dnsmasq
, you need to reload the dnsmasq daemon
:
sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
cp -r <vendor_path>/staempfli/magento2-builder-tool/config.sample/ config
core_config_data
on config/mg2-builder/magento/config.yaml
config.sample/mg2-builder/server/config.yaml
NOTE: You only need to replace parameters between <>
with your corresponding values. All other placehoders like ${}
or {{}}
will be automatically replaced during the tool execution
mkdir logs
vim logs/.gitignore
# Ignore everything in this directory
*
# Except this file
!.gitignore
You can customise all properties according to your needs:
config/mg2-builder/project.properties
have the highest priority and will overwrite default onesList available targets:
bin/mg2-builder -l
Project install:
bin/mg2-builder install
Sync data from server:
bin/mg2-builder sync
If you do not want to input over and over again the properties required, you can setup your default environment parameters as follows:
Create folder _conf
at one level higher than your project root.
Add a new file environment.properties
inside that folder.
Inside this file you can specify your environment properties as follows:
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>
To skip entering the ssh password every time, you can use ssh-copy-id
to automatically set the public-private keys on the server.
Simply execute:
ssh-copy-id user@server-domain
If you need additional scripts to build your projects, you can add them here:
config/mg2-builder/xmlscripts/custom.xml
You can also define targets that will be automatically executed during the build process.
This tool contains customHooks
that can be listened to dispatch other targets.
You can set inside config/mg2-builder/project.properties
the targets to be executed by these hooks:
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>
In order to use sync functionalities, n98-magenrun2
must be available on the remote server. The easiest way is to add it as part as your project dependencies:
composer require "n98/magerun2":"^1.4"
If you install n98-magerun2
in your server in another way, be sure to configure the parameter sync.bin.n98-magerun2
accordingly:
Problem: On Mac computers, MySQL
crashes sometime when creating, importing or updating the Magento database.
Solution: Kill MySQL process, start MySQL and try again:
killall -9 mysqld
mysql.server start
or mysql.server restart
mg2-builder install
GNU General Public License, version 3 (GPLv3)
(c) 2017 Staempfli AG