Using ddev for Shopware 6 Local Development

ddev is a light-weight, open-source tool for local PHP development environments. It is very easy, if not intuitive, to use, installation is simple and hassle-free (at least on my Ubuntu machine). Also, ddev integrates neatly with CI/CD, as all project specific stuff for ddev just goes into one folder. ddev supports xdebug and is perfect to work with phpstorm.

Read here on how to set up a local Shopware 6 enviroment with ddev in just 5 minutes.

Five Minute Setup Guide

These instructions assume that you have setup docker and ddev on your machine, as laid out here: https://ddev.readthedocs.io/en/stable/

There is also a quick guide on ddev docs: https://ddev.readthedocs.io/en/stable/users/quickstart/#shopware-6

This is the way I setup a project for my new clients:

  • Create a project folder, say ‘myproject’ and cd into it
  • Download Shopware (you may want to replace the version to reflect the most current one) and unzip:
  • Create a folder .ddev inside your project folder
  • Inside .ddev, create a file config.yaml and copy & paste the content below into it

You may want to replace “myproject” with a project name of your choice.

  • From inside your project folder run the command ddev start. Since ddev will modify your /etc/hosts file to link the project url, you will need to have your admin password at hand.
  • ddev will start four containers: a web server, a database server, a router and an ssh agent. The web server also has an integrated mailhog server to facilitate development and testing of mail templates.
  • Once ddev has fully come up, you can reach Shopware’s web installer via your browser using the url https://myproject.ddev.site.
  • Now install Shopware following the installer docs.
  • During the install process, when asked for database credentials, it is simply ‘db’ for the host, the user, the password and the database.
  • And that’s it – you are set with a local Shopware 6 installation!

Storefront and Admin Watcher

Some extra notes for using the storefront and admin watchers:

  • It does not work using https – so use http instead of https in your browser.
  • The file-change triggered automatic browser reload does not work with nginx (at least not out of the box) – so chose apache-fpm as the webserver type.
  • Add a file docker-compose.watcher.yaml to your .ddev folder

To reach Admin in watch mode, omit the ‘admin’ in the url: http://myproject.ddev.site:9997

To access the storefront in watch mode, you need to define a storefront in one of your sales channels with http, but omitting the port (i.e. do not (!) add the 9998 port to the domain). Then use a url like http://myproject.ddev.site:9998 to reach the watched storefront.

A more comprehensive and excellent guide on how to setup ddev for Shopware 6 can be found here: Installing / Developing Shopware 6 with ddev

Leave a Reply