Home Blog Contact

How to create a plugin in Shopware 6?

Jan 24th 2022

Hello, today I will explain how to create your first Shopware 6 plugin.

This is a very simple tutorial to help you to create a plugin the simplest way possible. There are more ways to create plugins and in case you want to understand other ways please make sure you visit the official documentation and get all the information available: Plugin Base Guide.

Plugin name: You can use any name but the convention says it's a good idea to use manufacturer + technical name for organization purposes. Here are some examples:

Name your plugin as you prefer. My example will be MatheusGontijoHelloWorld.

Create a plugin skeleton

Please, run the following command line:

php bin/console plugin:create MatheusGontijoHelloWorld

Shopware will create a basic structure for you on the location custom/plugins/MatheusGontijoHelloWorld. See the files:

├── composer.json
└── src
    ├── MatheusGontijoHelloWorld.php
    └── Resources
        └── config
            └── services.xml

Important Please, update the composer.json file to look the following example, otherwise it won't work. Pay attention on the highlighted lines:

  "name": "matheusgontijo/hello-world",
  "description": "Hello World plugin!",
  "type": "shopware-platform-plugin",
  "license": "MIT",
  "autoload": {
    "psr-4": {
      "MatheusGontijo\\HelloWorld\\": "src/"
  "extra": {
    "shopware-plugin-class": "MatheusGontijo\\HelloWorld\\MatheusGontijoHelloWorld",
    "label": {
      "en-GB": "This is my description!",
      "de-DE": "Das ist meine Beschreibung!"

Keep in mind that the type shopware-plugin-class is how Shopware recognizes you have a plugin on that directory. Without this reference, it shouldn't work.

Important Please, update the MatheusGontijoHelloWorld.php file to look like the following example, otherwise it won't work. Pay attention on the highlighted lines:

<?php declare(strict_types=1);

namespace MatheusGontijo\HelloWorld;

use Shopware\Core\Framework\Plugin;

class MatheusGontijoHelloWorld extends Plugin

This is the content of the services.xml file. No update need to be done in this file.

<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">



Install and active the plugin

In the command line, execute the following:

php bin/console plugin:refresh

You will get a result like that:

Shopware Plugin Service

 [OK] Plugin list refreshed

Shopware Plugin Service

 -------------------------- -------------------------------------------- --------- ----------------- ----------------- ----------- -------- -------------
  Plugin                     Label                                        Version   Upgrade version   Author            Installed   Active   Upgradeable
 -------------------------- -------------------------------------------- --------- ----------------- ----------------- ----------- -------- -------------
  MatheusGontijoHelloWorld   The displayed readable name for the plugin   1.0.0                       Matheus Gontijo   No          No       No
  SwagPayPal                 PayPal Products for Shopware 6               4.1.0                       Shopware          Yes         No       No
  SwagMarkets                Shopware Markets                             1.3.8                       shopware AG       Yes         Yes      No
  SwagPlatformDemoData       Shopware 6 Demo data                         1.0.8                       shopware AG       Yes         Yes      No
 -------------------------- -------------------------------------------- --------- ----------------- ----------------- ----------- -------- -------------

 4 plugins, 3 installed, 2 active , 0 upgradeable

Now that our plugin is being loaded, let's install & activate it. Run the command:

php bin/console plugin:install --activate MatheusGontijoHelloWorld

You should have received a result like that:

Shopware Plugin Lifecycle Service

Install 1 plugin(s):
* The displayed readable name for the plugin (v1.0.0)

Plugin "MatheusGontijoHelloWorld" has been installed and activated successfully.

[OK] Installed 1 plugin(s).

! [NOTE] You may want to clear the cache after activating plugin(s). To do so run the cache:clear command

Congratulations! At this point you successfully created your very first Shopware 6 plugin!