PLUGIN DEVELOPMENT

Building Your First Shopware 6 Plugin

By Huzaifa Mustafa • 10 min read • January 8, 2026

Quick Answer

Creating a custom plugin is the most essential skill for extending Shopware 6. A "Plugin" in Shopware 6 is essentially a Symfony bundle with extra metadata. Here's the fastest way to get started:

php bin/console plugin:create MyFirstPlugin

This command scaffolds everything you need in custom/plugins/MyFirstPlugin. Then install and activate with plugin:install --activate.

Shopware 6 is built on a modern tech stack: Symfony 6+, Vue.js 3, and Twig. Unlike Shopware 5, it relies heavily on standard Symfony bundles. This architecture means that plugin development follows familiar Symfony patterns, making it accessible to PHP developers with framework experience.

This guide covers everything you need to create your first plugin: the easy CLI method, the manual setup (for deeper understanding), lifecycle hooks, and critical production optimizations.

1. The Easy Way: Using the CLI Generator

Shopware provides a console command to scaffold plugins instantly. This prevents human error in directory structures and ensures all required files are created correctly.

Step 1: Open your terminal

Navigate to your Shopware root directory where bin/console is located.

Step 2: Run the creation command

php bin/console plugin:create MyFirstPlugin

What gets created

This creates the following structure in custom/plugins/MyFirstPlugin:

custom/plugins/MyFirstPlugin/
├── src/
│   └── MyFirstPlugin.php    # The main entry class
└── composer.json            # Metadata and autoloading

Pro Tip: The CLI generator handles namespace configuration and PSR-4 autoloading automatically. For custom or complex plugins, you may want to understand the manual setup process below.

2. The Manual Setup (Understanding How It Works)

Understanding the manual setup helps you debug issues and customize plugins beyond the default scaffold. The critical file is composer.json - it tells Shopware "I exist."

The composer.json file

Create custom/plugins/MyFirstPlugin/composer.json:

{
  "name": "my-vendor/my-first-plugin",
  "description": "My first Shopware 6 plugin",
  "type": "shopware-platform-plugin",
  "version": "1.0.0",
  "license": "MIT",
  "autoload": {
    "psr-4": {
      "MyVendor\\MyFirstPlugin\\": "src/"
    }
  },
  "extra": {
    "shopware-plugin-class": "MyVendor\\MyFirstPlugin\\MyFirstPlugin",
    "label": {
      "de-DE": "Mein erstes Plugin",
      "en-GB": "My First Plugin"
    }
  }
}

Key Note: The extra.shopware-plugin-class line is critical. It points Shopware to your main bootstrap file. If this is wrong, your plugin won't be recognized.

Understanding the configuration

  • type: Must be shopware-platform-plugin for Shopware to recognize it
  • autoload.psr-4: Maps your namespace to the src/ directory
  • extra.label: Plugin name shown in the admin panel (supports multiple languages)

3. The Bootstrap Class

The bootstrap class is the entry point for your plugin. It extends the core Plugin class and allows you to run code during installation, updates, or uninstallation (e.g., creating database tables).

Create the main plugin file

Create custom/plugins/MyFirstPlugin/src/MyFirstPlugin.php:

<?php declare(strict_types=1);

namespace MyVendor\MyFirstPlugin;

use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\InstallContext;

class MyFirstPlugin extends Plugin
{
    public function install(InstallContext $installContext): void
    {
        // Logic to execute during installation (e.g., create a table)
        parent::install($installContext);
    }
}

Available lifecycle methods

The Plugin class provides several lifecycle methods you can override:

  • install(): Called when the plugin is first installed
  • update(): Called when updating to a new version
  • uninstall(): Called when removing the plugin
  • activate() / deactivate(): Called when toggling the plugin state

4. Installing & Activating Your Plugin

Once your files are in place, you must register the plugin with Shopware using console commands.

Step 1: Refresh the plugin list

Tell Shopware to scan for new plugins:

php bin/console plugin:refresh

Step 2: Install and activate

Install and activate in one command:

php bin/console plugin:install --activate MyFirstPlugin

Step 3: Clear the cache

Always clear the cache after structure changes:

php bin/console cache:clear

Verification: Your plugin should now appear in the Shopware admin under Settings > System > Plugins. You can also verify with php bin/console plugin:list.

5. Development Workflow: Hot Reloading

If you're developing storefronts (CSS/JS) or Administration modules, you don't want to manually compile assets every time you save. Use the "hot module replacement" watchers:

For Storefront (Frontend)

./bin/watch-storefront.sh

For Administration (Backend)

./bin/watch-administration.sh

These watchers automatically rebuild assets when you modify files, giving you near-instant feedback during development.

Pro Tip: For even faster builds, consider using shopware-cli which uses esbuild and can start the admin watcher in under a second. See our Shopware CLI Guide for details.

6. Production Performance Checklist

Shopware 6 is feature-rich but can be heavy if not optimized. Before you go live, check these critical items:

1 Environment Configuration

Ensure your .env file is set to production mode:

APP_ENV=prod

2 HTTP Cache Warm-up

Verify the HTTP cache is active and warm it up:

php bin/console cache:http:warm-up

3 Message Queue Configuration

Don't run tasks synchronously. Use the message queue (RabbitMQ or Doctrine) to handle heavy tasks in the background:

  • Email sending
  • Product indexing
  • Import/export operations

Quick Reference Commands

Plugin Creation

  • plugin:create PluginName
  • plugin:refresh
  • plugin:install --activate PluginName

Cache Management

  • cache:clear
  • cache:http:warm-up

Development

  • ./bin/watch-storefront.sh
  • ./bin/watch-administration.sh

Plugin Management

  • plugin:list
  • plugin:uninstall PluginName
  • plugin:update PluginName

Need Help Building a Custom Plugin?

Whether you're building payment gateways, custom themes, or complex integrations, get expert guidance from a Certified Shopware Developer.

Talk to an Engineer