Create Your Own Development Environment for Shopware to Build Apps and Plugins
Here, I will show you how I work with Shopware on a Windows environment. Most of what I share comes from my day job. This way of working has evolved over time through lessons learned and the need to make my life as a developer easier.
Developing in Shopware
For almost all my coding and development, I use VS Code. I won't go into details about what VS Code is or how to use other IDEs or VS Code with Docker. You can view this blog as a small guide to how I develop in Shopware and pick out the parts that are useful to you. My goal is to show you how to set up your own development environment so you can build your own plugins and apps. I'll include links to all relevant sources and documentation.
Things you need to work with Shopware in a Windows environment
- WSL2 installed and enabled.
- Docker installed and properly configured.
- At least 32GB of RAM to provide sufficient memory for WSL2.
- Adequate free disk space.
- Basic knowledge of the terminal and how to use it.
32GB of RAM is not a hard requirement. You can manage with less, but my advice is: more is better. I also changed the WSL settings to allocate about 30GB of RAM on my system. When using dev mode, a lot happens in Shopware. The more extensions you use, the more RAM Shopware needs. There's nothing more annoying than having your shop in dev mode and waiting for things to respond. Don't forget to leave enough RAM available for your system to run smoothly.
Preparing
From this point onwards, I assume your system has everything installed and is ready to use Docker. I like to create folders for every project I work on. My system has multiple hard drives, and to make my life easier, all my projects are stored on one of my hard drives, making them easy to find via the CLI or just the Explorer. Let's say the path to my projects is G:\_DEV. The underscore (_) in front of the folder name moves the folder to the top when sorting by name.
Inside this folder, there are more subfolders to organize different types of files and a folder for libraries or development dependencies. I will focus only on the important parts. For Shopware projects, I use a folder called shopware_projects. Inside it, there are folders for each project. The reason for this is that I use docker-compose.yml files to manage my project containers.
The folder structure could look like this:
WSL-Configs
To configure your WSL2, you have to open up the .wslconfig file insiede your user Profile Folder. You can open up your profile folder quickly with %userprofile%. In most cases, the .wslconfig dose not exist if you newly installed the WSL2. You can also use the configuration-tool provided by Windows. Just search for wsl-settings, then open the application. Here you can change a lot of settings. Please read the documentation before you change any of the settings.
The same is possible within the .wslconfigs
Docker and Compose setup
Now we need to create a configuration for our development environment. For this, I use the docker-compose.yml file. It allows me to easily manage my Dockware containers.
The docker-compose.yml file
I will now add an docker-compose.yml in my first-time-shopware folder. Here is a configuration example. More can be found in the Dockware documentation.
Starting Dockware
Starting the container is easily done with the terminal. You only need to open the terminal in the folder
location of your project. In my example, I open the path to
G:\_DEV\shopware_projects\first-time-shopware. Here you type docker compose up -d to
start the container stack. After you are done with coding, you can stop the container with
docker compose stop, or you can also remove the container stack with
docker compose down. Dropping the stack is no problem here, as long as you use persistent
volumes like we do in our compose config file. You can restart the container if it has been stopped using
docker compose start.
And that's it! You now have a system-independent development stack for your coding needs. When I have some free time, I'll write a blog post about how I use VS Code with this Docker setup. It's also possible to automate tasks, like adding your Git repository to the plugin folder inside the Shopware container. You now have a way to do create a shopware environment for coding efficiently. Here's a good tip: if you need this exact environment and any custom scripts in the future, just save it as a Git repository.