Magento2 Deployment with Deployer (Skeleton)

Last update: Jul 18, 2022

MageDeploy2 Base

Magento2 Deployment Setup using Robo and Deployer. This is the base project you should base your deployments on. It provides an configurable and customizable setup to create push deployments for Magento2.

Getting Started


  • deployer/deployer
  • consolidation/robo
  • mwltr/magedeploy2
  • netz98/n98-deployer


MageDeploy2 requires deployer and robo to be available on your system.

Those Tools can be used globaly or added as a requirement to your local composer.json.

The path to those tools can be configured in the magedeploy2.php

Furthermore gtar ( gnu-tar) is required, it can be installed via brew

brew install gnu-tar


Create a new deployment setup

composer create-project mwltr/magedeploy2-base <dir>

Robo needs to be installed using composer, otherwise the usage of custom Tasks is not available. See the Robo Documentation Including Additional Tasks

Configure Deployment

This tool assumes you have a git repository containing the magento composer.json. Furthermore your local build environment can clone said repository and download the Magento packages using composer.

MageDeploy2 Configuration

To configure the MageDeploy2 use the following command:

./vendor/bin/robo config:init

It will guide you throught the most important configuration options. Don't worry you can edit the magedeploy2.php lateron.

Next, run

./vendor/bin/robo validate

to validate your build environment is setup.

Setup local build environment

If you are done with the configuration in magedeploy2.php, you can see if your build environment can be setup. To do so run this command:

./vendor/bin/robo deploy:magento-setup develop

You can use a different branch depending on your git repository setup.

After the magento-setup has run successfully, you can now generate the assets by running the command:

./vendor/bin/robo deploy:artifacts-generate

After this command is complete you should see the packages beneath shop.

At this point we are sure that the local build setup is working and we can now continue with releasing our project.

Deployer Configuration

After the Installation and general configuration of magedeploy2, you have to edit the deploy.php file to suit your needs. To evaluate we will create a local deployment target. To do so create run

cp config/local.php.dist config/local.php

and set the config values according to your local deploy target.

Check the configuration in deploy.php and adjust it to your requirements. The default configurations and tasks are defined in \N98\Deployer\Recipe\Magento2Recipe. You can also have a look at all the configurations available in the Deployer Documentation

Setting up deploy directory tree

After you are done with setting the configuration, you can now initialize the directory tree of the deploy target run

./vendor/bin/dep deploy:prepare local

This will create the required directories on your local deploy target.

Setting up deploy target (optional)

If you want to set up your deploy target as well you can use the command

./vendor/bin/dep server:setup local

It will make an initial deployment to push your code to the deploy target.

When this is done navigate to your local deploy_path and run the magento install command to setup the database. This might look something like this:

cd <deploy_path>
php bin/magento setup:install --db-host= --db-name=magedeploy2_dev_test_1_server --db-user=root [email protected] 
--admin-firstname=Admin --admin-lastname=Admin --admin-password=admin123 --admin-user=admin 
--backend-frontname=admin --base-url=http://magedeploy2_dev --base-url-secure=https://magedeploy2_dev 
--currency=EUR --language=en_US --session-save=files --timezone=Europe/Berlin --use-rewrites=1

Now we have Magento database and configuration on our deploy target and are ready to continue with the final step.

Deploying the project

At this point, you have setup the build environment and target environment and can finally start with the actual deployment. You can do so by running:

./vendor/bin/dep deploy local

Congrats you have successfully setup your deployment pipeline and run the first deployment!



This is the config file to set all parameters required for the deployment in general.

The most common settings are to adjust on a project basis:

  • deploy/git_url (path to your git repository)
  • deploy/themes (the themes that are to be generated)
  • build/db (the database settings for the build environment)

A complete list of configuration options is provided further down.


Key Description Default
git_bin Path to git executable /usr/local/bin/git
php_bin Path to php executable /usr/local/bin/php
tar_bin Path to tar executable /usr/local/bin/gtar
composer_bin Path to composer executable /usr/local/bin/composer.phar
deployer_bin Path to deployer executable /usr/local/bin/deployer.phar


Key Description Default
git_url Git-Url to your repository
git_dir Sub-directory on build server to clone the repository to shop
app_dir If you have your magento composer.json in another sub-dir
themes An array of themes to compile
assets List of assets to generate
clean_dirs list of dirs to clean on each deployment


Contains the database configuration being used to create and update a local magento setup during deployment.


This file is for the actual deployment of your project to the server. It has a basic setup that should work on most of the environments. You can adjust this to your needs as well. Leave out unwanted steps, add new ones, exchange existing ones, etc.

The deploy.php uses the N98\Deploy\Recipe\Magento2Recipe as base recipe and overwrites some of the default settings.

The server configuration is defined using the config/*.php files.



Replace all ADD_XXX to suit your demands.

Files to customize and check:


This deployment uses a native ssh client with a ssh-config file per default. It needs to be defined in .ssh/config and needs to match with your server configs beneath config.


The Hostname in the .ssh/config has to be an IP otherwise an error during the deployment will occur.


A list of known hosts can also be added within this directory: .ssh/known_hosts Keys can be added here, e.g.

  • ssh-rsa {long_public_key}
  • ssh-rsa {long_public_key2}


Take a look at config/production.php and config/staging.php` and change it accordingly.


The Jenkinsfile defines the Jenkins Pipeline. It has to be adjusted to the project needs.


deploy.php is the main entry point that can be used to customize.

Getting Started

Install dependencies with composer install

start deployment with ./dep deploy staging



Generate a new magedeploy2.php. Be aware: this will overwrite your existing configuration


Validates that

  • the bin config values are execuatble,
  • the git repository is reachable


Triggers the deployment with all it's stages


Runs all tasks in the stage magento-setup. It will setup or update a local Magento instance by pulling the source-code from git, installing composer dependencies and installing or updating a local database.


Runs the Magento di:compile and setup:static-content-deploycommands to generate the assets. It is using your configurartion from the magedeploy2.php.

After generating those assets it will create packages, again according to your configuration.


This command will invoke deployer to release your project and push the prepared artifacts to the server.


We use SemVer for versioning. For the versions available, see the tags on this repository.


  • Matthias Walter - Initial work - mwr


This project is licensed under the MIT License - see the file for details

  • 1. What is the new expected way to run cleanup

    I noticed CleanupTasks was removed from n98/deployer, also your upgrade documentation mentions removing CleanupTasks from the pipeline.

    I wonder how are release rotation supposed to be handled in the new version.

    Reviewed by barbazul at 2017-10-04 22:23
  • 2. Add a task/step to build assets with HTTPS

    If you are planning on using HTTPS (which, you should) Magento requires an additional run of static-content:deploy with the environment variable HTTPS set to "on" in order to produce output in the secure subfolder.

    Now, the only files generated in this subfolder are requirejs configuration files, so the second run does not need to recreate all the JS and CSS.

    Right now, I am running the following command manually after each deploy (we are not yet on production) which fix the issues found:

    export HTTPS=on; php bin/magento setup:static-content:deploy --no-javascript --no-css --no-less --no-images --no-fonts --no-html --no-misc --no-html-minify en_US es_AR

    The --no-* arguments prevent all assets from being generated again.

    This extra run should be mandatory, and not optional I think (it should be part of the default Magento command).

    Reviewed by barbazul at 2017-05-13 15:42
  • 3. Prevent error "Call to undefined function Deployer\local()"

    When following the readme an error "Call to undefined function Deployer\local()" occured while using the "local" deployment based on the file config/local.php.dist.

    When changing the function call to $local = localhost('local'); everything works as expected.

    Reviewed by decius7bc at 2017-07-16 12:04
  • 4. cachetool not compatible with php < 7.1 anymore

    The task "cachetool:clear:opcache" from "deployer/recipies" always downloads the most up to date version. As of today this is version 4.0.0. But this is not compatible with PHP versions smaller than 7.1 anymore (

    The deployer recipe is already updated and can be used with version 6.1.2 ( But currently the composer.json here does not load the 6.1.x versions.

    Reviewed by shuryoka at 2018-05-31 07:42
  • 5. Initial Deployments - Init Database

    For first time deployments to a server it might be helpful to have a command available that can initialize the database on the remote server for us.

    The connection to that database would need to provided some how.

    Not sure yet how to achieve this in the best way.

    Reviewed by mwr at 2017-03-06 14:25
  • 6. Add Documentation on how-to add custom RoboTasks or DeployTasks

    Per project one might have to have to customize exsting tasks or add additional tasks.

    There needs to be some documentation on how to create local tasks beneath a src dir. Furthermore some doc on how to include tasks using composer might be helpful as well.

    Reviewed by mwr at 2017-03-06 14:21
  • 7. Create environment specific configuration (local/build)

    At the moment there is only one magedeploy.php with one configuration for the build database. The database authentication data might probably differ between local setups and a build-server. So there needs to be a solution on having both.

    Reviewed by mwr at 2017-03-06 14:19
Extract and evolution of the magento2-currency-precision module from the magento2-jp project from @Magento

Currency Precision Module for Magento 2 This module aims to help merchants to manage easily their currency precision in Magento 2. DISCLAIMER Initiall

Dec 17, 2021
Magento2 Turkish Translation / Magento2 Türkçe Çevirisi
Magento2 Turkish Translation / Magento2 Türkçe Çevirisi

Magento 2 Türkçe Dil Paketi Magento2 için Türkçe Dil Paketi Magento2 içinde standart olarak gelen tüm tercüme dosyaları derlenmiş ve bu paket oluşturu

Mar 27, 2022
Tool based on to perform zero downtime deployments of Magento 2 projects

Magento 2 Deployer Plus Reliable fully-automated deployments tool for Magento 2. Zero downtime deployments on Magento versions >= 2.2 Automating your

Apr 28, 2022
Docker-magento2 - 🐳 Docker containers with all required Magento 2 dependencies installed available as FPM through Nginx and CLI

Magento 2 Docker A collection of Docker images for running Magento 2 through nginx and on the command line. Quick Start cp composer.env.sample compose

Jun 9, 2022
Magento2 + Varnish + PHP7 + Redis + SSL (cluster ready)

Docker Magento2: Varnish + PHP7 + Redis + SSL cluster ready docker-compose infrastructure Infrastructure overview Container 1: MariaDB Container 2: Re

May 7, 2022
Guest to Customer for Magento2 - Quickly and easily convert existing guest checkout customers to registered customers.
Guest to Customer for Magento2 - Quickly and easily convert existing guest checkout customers to registered customers.

Guest to Customer for Magento 2.0 For Magento 2.0.x, 2.1.x, 2.2.x, 2.3.x and 2.4.x In general E-commerce, shoppers do not like to create an account du

Jul 15, 2022
Magento2 British Language Pack (en_GB)

Links Website: What's Up With The Fork? This fork is created from the original for 3 main reas

Apr 28, 2021
Magento2 Spanish (Argentina) language pack build from Crowdin community translation tool.

Magento2-language-es_ar Magento2 Spanish (Argentina) language pack build from Crowdin community translation tool. Paquete de idioma de Español (Argent

Apr 7, 2021
Simple Gulpfile for Magento2

Magento 2 gulpfile Gulp tasks and configuration necessary to setup gulp-based front-end workflow for deploying and watching theme customizations. Requ

May 18, 2021
Developer Toolbar for Magento2
Developer Toolbar for Magento2

Developer Toolbar for Magento2 About Hope this debug toolbar can speed up Magento2 development module. Any feedback and idea to improve this toolbar w

Aug 9, 2022
A simple script to convert extensions from Magento1 to Magento2

ConvertM1M2 Background The purpose of this script is to automate as much as possible the initial conversion of a Magento 1 extension, and allow develo

Jun 20, 2022
Magento2 Plugin for Conversion Pixel/API of Tiktok

Tiktok Conversion Pixel Analytics Plugin Magento2 Table of Contents About Getting Started About Tiktok Pixel is the Plugin used to track events, which

Jun 27, 2022
Laradeploy offers you to automate deployment using a GitHub webhook.

Introduction Laradeploy offers you to automate deployment using a GitHub webhook. Simple and fast just make a git push to GitHub deploy the new modifi

Feb 21, 2022
Nextcloud AIO stands for Nextcloud All In One and provides easy deployment and maintenance with most features included in this one Nextcloud instance.

Nextcloud All In One Beta This is beta software and not production ready. But feel free to use it at your own risk! We expect there to be rough edges

Aug 14, 2022
Magento Deployment Scripts

Magento Deployment Scripts Author: Fabrizio Branca This is a collection of scripts used to build/package, deploy and install Magento projects. Import

Jan 1, 2022
Lumen on Docker - Skeleton project with Nginx, MySQL & PHP 8 | Aws ECS, Google Kubernates, Azure Container Engine

Docker infrastructure for Lumen Description Microservice Lumen is a starting skeleton based on Docker and Lumen Framework. This project helps to devel

Aug 7, 2022
🧬 Nano is a zero-config, no skeleton, minimal Hyperf distribution that allows you to quickly build a Hyperf application with just a single PHP file.

Nano is a zero-config, no skeleton, minimal Hyperf distribution that allows you to quickly build a Hyperf application with just a single PHP file.

Aug 2, 2022
Deployer is a free and open source deployment tool.

Deployer Deployer is a PHP Application deployment system powered by Laravel 6.0, written & maintained by Stephen Ball. Check out the releases, license

Aug 14, 2022
Deployer based deployment for WordPress with media and database synchronisation.

deployer-extended-wordpress What does it do? Should I use "deployer-extended-wordpress" or "deployer-extended-wordpress-composer"? Dependencies Instal

Jun 3, 2021
Deployer is a PHP Application deployment system powered by Laravel

Deployer is a PHP Application deployment system powered by Laravel 5.5, written & maintained by Stephen Ball.

Aug 9, 2022