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.
Shopware provides a console command to scaffold plugins instantly. This prevents human error in directory structures and ensures all required files are created correctly.
Navigate to your Shopware root directory where bin/console is located.
php bin/console plugin:create MyFirstPlugin
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.
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."
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.
shopware-platform-plugin for Shopware to recognize it
src/ directory
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 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);
}
}
The Plugin class provides several lifecycle methods you can override:
Once your files are in place, you must register the plugin with Shopware using console commands.
Tell Shopware to scan for new plugins:
php bin/console plugin:refresh
Install and activate in one command:
php bin/console plugin:install --activate MyFirstPlugin
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.
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:
./bin/watch-storefront.sh
./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.
Shopware 6 is feature-rich but can be heavy if not optimized. Before you go live, check these critical items:
Ensure your .env file is set to production mode:
APP_ENV=prod
Verify the HTTP cache is active and warm it up:
php bin/console cache:http:warm-up
Don't run tasks synchronously. Use the message queue (RabbitMQ or Doctrine) to handle heavy tasks in the background:
Continue learning about Shopware development:
Whether you're building payment gateways, custom themes, or complex integrations, get expert guidance from a Certified Shopware Developer.
Talk to an Engineer