Getting rid of deprecation messages in Symfony console

You all have seen these pages full of deprecation messages when using console commands in a Shopware 6 development environment. Sometimes it’s hard to find the actual output in between all these info level message. Running the command in quiet mode with -q is not a solution, as it will suppress any output.

In general it is a good idea to show developers deprecation messages, and you as a developer should carefully inspect these. (And not, later, complain on broken backward compatibility when you could have known for years.) However, if you are not concerned with the code in question, it’s just annoying.

So this is how to turn these messages off: In your framework.yaml file (within the config/packages folder in your project), add these lines:

The main level controls the messages written to the dev.log file, while the console level and verbosity_level controll what is output to the console. The above setting will suppress all messages of level info and below.

Enyou your clean console screens!

Shopware 6 App Server Development with ddev

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’):

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

Continue reading “Shopware 6 App Server Development with ddev”

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.

Continue reading “Using ddev for Shopware 6 Local Development”

Setting up a Cloud Server

Running servers in the cloud – like with AWS, Digital Ocean or Hetzner – is a cheap and easy way to get hold of a high performance server for a Shopware installation, be it development, staging or production. Though many are afraid of the technical knowledge required to set it up. It is probably easier than you believe.

A cloud server typically gives you more bang-for-the-buck (i.e. power/€) than a shared hosting or a managed server. Furthermore, it is scalable – you can size it up – or down – as you need, while you pay only for the actual resources booked. With all providers, a cloud server can be booked and is up within minutes, and can be cancelled effective immediately with a mouse click.

Read here how to quickly set-up a cloud server. It’s just six steps:

  1. Book and Create a Server
  2. Server Basics
  3. Install LAMP Packages
  4. Letsencrypt SSL
  5. Configure Apache
  6. Install Shopware

Before we start

This example assumes that you have a domain, and have registered this domain with your Shopware account.

The command and code examples are taken from our experience with Hetzner, so they might slightly differ for AWS or Digital Ocean servers.

Our example is based on the LAMP stack with Apache2 as the webserver and mySQL as the database. If you prefer nginx and/or mariaDB have a look at this excellent tutorial:

Book and Create a Server

First thing to note is terminology: While at Hetzner a server is a server, Digital Ocean calls it a ‘droplet’ and for AWS it is an ‘EC2 instance’.

Hetzner cloud servers are amongst the cheaper alternatives, so this is what we start with. To be fair, while Digital Ocean and AWS are more expensive, they also provide (apparently) a higher level of reliability and performance.

For a first Shopware installation, you might want to start with a Hetzner CX21 server, which comes with 2 CPUs, 4 GB of memory and 40 GB of disk space. It’s just € 5,83 per month (at the time of writing).

Select Ubuntu 20.04 as an image, and add your SSH public key for access (never ever use password login with your servers).

Once you have created the server, it is a good idea also to create a firewall and assign it to your server. The only incoming traffic you should allow is TCP ports 22 (for SSH) and 80 and 443 (for the web server).

Server Basics – Users, Firewall

Before starting anything else you should update your server to using the most up-to-date libraries:

The first thing you should do is to add a non-root user and enable sudo without password for it. There are excellent tutorials for this:

Set up non-root user:

Enable sudo without password:

Then you should harden your SSH a little bit – at least disable root login and login with password, as explained here:

Last but not least I recommend to enable ufw (‘uncomplicated firewall’). It should be installed already by default, if not, install it with:

Enable ufw and open the SSH and web server ports. The trick with SSH is the ‘limit’ which prevents brute force attacks.

Verify ufw’s status with sudo ufw status. Before you continue or log out, open a second ssh terminal and log in to proof that you have not accidentally locked yourself out.

Install Apache2, MySQL and PHP

When you created the server, you may have noted that there is also an ‘app’ with a pre-configured LAMP stack that you could use to create the server. If you did so, you may skip the corresponding parts in this section. Note I personally prefer to set up the stack my self, as I don’t fully trust what’s in the app provided.

Install the basic Apache2, MySQL and PHP components:

You also need to install a no. of PHP extensions required by Shopware 6:

Now update your php.ini settings to Shopware 6 requirements. The php.ini file is located in /etc/php/7.4/apache2/php.ini. Check and correct these settings if necessary:

Furthermore, enable the Shopware-required Apache modules and restart Apache:

Now prepare MySQL and create the user and databases for Shopware. Before you start, I recommend to use the mysql_secure_installation tool as described in this tutorial:

Whenever prompted for a new password, you may want to use the pwgen tool to create it. For example

will output a 32 character strong password.

First, log into MySQL as a root user – since you do it ‘locally’ you don’t need the password here:

Now, from the console, create a user and databases (we assume we will have a staging and a production environment on our server).

Now log into MySQL as the shopware user to test whether all settings are correct:

You will be prompted for the password. Check whether you have the necessary privileges for the tables:

You should see the databases staging and production.

Letsencrypt SSL

Letsencrypt is great provider for free SSL certificates, that are required to run your web server in secure https mode. The tool you need to use it on your server is called certbot – install it with:

Do a dry-run first to check everything is working on your server:

When asked ‘How would you like to authenticate with the ACME CA?’ chose option 2 (place files in webroot directory). The webroot directory to specify is /var/www/html. After the dry-run finishes successful, repeat the command without the dry-run option. You will find the certificates in this folder: /etc/letsencrypt/live/

The really smart feature of certbot is that it will, in the future, automatically renew the certificates for you when they expire (usually every three month).

Configure Apache2

Apache allows you to support multiple hosts from one server – so called virtual hosts or vhosts in short. Although not necessary, I recommend to configure vhosts right away.

Create a new directory to host the Shopware installation and assign it to the web server:

Now go into the directory /etc/apache2/sites-available and create a new file 10-example.conf.

Paste the code below into this file and save.

Now disable Apache’s default vhost, enable your new vhost and restart Apache:

Install Shopware

Now go to your vhost document root directory and create the Shopware 6 installation files. It is important to note that, since you are now in the ‘domain’ of the web server, you need to prefix all your commands with a sudo -u www-data.

To get the correct download link, visit and copy the link using a right-click (!) on the ‘Install’ button for the selected version.

Now point your browser to – you should see Shopware 6′ setup wizzard. Follow all steps as appropriate.

Questions? Remarks? Suggestions?

Please share your insights and thoughts using the comment section below!

Adding Custom Fields to Forms

One of Shopware 6′ the most useful features for shop owners is the ability to add custom fields to almost any entity. Some benefits of custom fields are:

  • Can be defined and edited via admin out-of-the-box
  • Allow almost any field format
  • Can be grouped in logical groups

However, there is no standard mechanism that would make a custom field available for display in the storefront. You will need to extend your theme’s Twig templates to make custom fields visible for shop users. This is a straight-forward task, described very well in the docs:

In this post, I am going to demonstrate how you can add a custom field to a form, so that a user would even be able to submit additional data.

Continue reading “Adding Custom Fields to Forms”

Using Twig’s ‘filter’ and ‘sort’ Filters

When, like many Shopware developers, you switch from Smarty (Shopware 5) to Twig (Shopware 6), or anyhow you are new to Twig, you should take your time to go through Twig’s excellent documentation – it’s worth while!

Twig comes with some really nice features that help you to improve readability of your code. Like, did you know, that you can use Twig’s filters not just with variables, but also for functions? One example are the filter and sort functions available with the for function.

Continue reading “Using Twig’s ‘filter’ and ‘sort’ Filters”

Retrieve Sales Channel-specific Data for Products

Shopware 6′ product entity has some properties that are dependent on the actual sales channel. When you retrieve a product from inside a controller or service using the ‘standard’ product repository, you will notice that these properties are not set. So how to you get hold say of the cheapest price for a product in a given sales channel?

Here is how to do it:

Continue reading “Retrieve Sales Channel-specific Data for Products”

Adding a Custom Field as Extension

Shopware 6′ custom fields is a very powerful yet easy to use mechanism to customize the standard data model and functionality. Custom fields for an entity are stored in a pre-defined json field with that entity. This mechanism is very flexible, and allows even out-of-the-box translations for custom fields, however it has two major flaws:

First, it creates some inevitable performance overhead. If you need to search that field (say an ERP product id) from a PHP script, be aware that, since it is wrapped in an SQL json field, there is no related database index.

Second, it relies on a pre-defined json field being defined for that entity. If the makers of Shopware decided to leave that off for an entity, that’s it – no custom fields for this entity.

Luckily, there is a simple alternative to custom fields provided in Shopware’s Data Access Layer (DAL) entity extensions. While it needs a litte bit more code than a simple custom field, there is no big magic behind it. Read and learn here how to create additional fields for any entity in Shopware 6.

Continue reading “Adding a Custom Field as Extension”

Database Management with Shopware 6

Inevitably, at one point you’ll have the need to access the database directly. Some practical use cases can be found in the docs:

So, what’s the best tool then to use? The particular challenge when it comes to Shopware 6 arises from its use of binary value UUIDs – they are just not “human readable” by default. Many database manage tools however are able to display UUIDs in a human readable format – the so-called hexadecimal or, short, hex format.

Continue reading “Database Management with Shopware 6”