Shopware 6 App Server Development with ddev

ddev (https://github.com/drud/ddev) is an extremely easy to use docker environment. Even though it does not provide all the degrees of freedom you will get with a custom docker-compose installation, I find it helpful in particular as a development environment for our client projects. It integrates very well with github/gitlab and the deployment pipelines.

In an earlier post, I have explained how to use ddev for setting up a local development environment for Shopware 6 (‘five minute setup guide’): https://vanwittlaer.de/using-ddev-for-shopware-6-local-development/

Read here how to set up a local development environment for both an app server and a Shopware 6 client.

Shopware 6′ app concept is explained in detail here: https://developer.shopware.com/docs/concepts/extensions/apps-concept A Shopware 6 app consists of two parts: One, that resides with the Shopware installation itself, like an ordinary extension (or plugin, as we used to say). Let me call it the ‘app client’. The other part is an app server, needed to provide additional functionality otherwise not available within Shopware 6. In fact, the app server part is optional, and you will see that many apps in the store just bring an app client.

Now when you develop an app server component for your Shopware 6 app, you basically need a second local, independent development environment that provides the needed containers for the app server. ddev is a perfect tool for this, as all web server set up with ddev expose individual unique ports and thus can run in parallel on your local machine.

For your convenience, I have created an example app server template on github: https://github.com/vanWittlaer/S6AppTemplate You may want to check it out before continuing.

For this tutorial I assume that you have installed docker and ddev on your machine as described in the docs: https://ddev.readthedocs.io/en/stable/

As a first step, edit .ddev/config.yaml and adjust it to your needs.

Adjust the environment (webserver_type, php_version, mysql_version) to your needs (typically it should be similar to the expected production server). Note that the name of your project becomes the DDEV_SITENAME to be used in the project url, so you may want to keep it short. It can be different from the name of your app!

Create a .env.local file in your project root and edit it like this:

Then start ddev with ddev start from inside your project folder. SSH into your container with ddev ssh, and then run composer install and bin/console doctrine:migrations:migrate. That’s it, your are set.

You may want to create a unique app secret using the command bin/console regenerate-app-secret. Copy the generated secret as appSecret into the .env.local file. (Obviously this only works after you have run composer install.)

To setup the corresponding app client site, I recommend to install a ddev based Shopware 6 environment as described here: https://vanwittlaer.de/using-ddev-for-shopware-6-local-development/

Now copy the entire folder custom/apps/VanWittlaerExampleApp from your app server into your app client. You may need to edit the registrationUrl and webhook urls in the manifest.xml file to replace the ‘myapp’ part with the name you chose for your project. Also, fill out the secret with the one generated for the app server in the previous step. Install and activate the VanWittlaerExampleApp using the Admin of your app client installation.

Container-to-Container Communication

For two local ddev containers to talk to each other, curl on the client side has to trust the ssl certificate of the server side. This needs some extra ddev configuration between the two web containers.

Add a docker-compose.links.yaml file to your .ddev folder on both the app server and the app client side. On the client side, this file should look like this:

<name of your project> is the name of your app server project.

On the server side, the corresponding client needs to be defined like this: