Chapter 1: Set up your environment
WARNING
Single File Component (SFC) support for Administration extensions is experimental. It is available since Shopware 6.7.16.0. The APIs described on this page can still change without a deprecation. Try it out and tell us what you find, but do not ship an extension built on it to customers or to the Shopware Store until the API is declared stable (planned for 6.9).
At the end of this chapter you have a running shop in Docker and an installed plugin that does nothing yet. The first .vue file comes in Chapter 2.
A shop to develop against
Before you start, install Docker and Shopware CLI. Every step of this tutorial uses them.
In your terminal, go to the directory where the tutorial project should live, and create a shop from the trunk branch:
shopware-cli project create swag-sfc-tutorial dev-trunk --dockerdev-trunk installs the current state of trunk, so you get the newest state of the experimental API. Any release from 6.7.16.0 on works as well. Then start the shop:
cd swag-sfc-tutorial
shopware-cli project devThat starts the containers, installs Shopware if it is not installed yet, and opens a dashboard with the shop URL, the admin URL and the credentials.
Running commands inside the container
PHP and the database run inside the containers, and the service hostnames the shop is configured with only resolve there. So every command that touches the shop has to run inside the web container:
Everywhere below, console commands are written as shopware-cli project console …. In a shell inside the web container, bin/console … does the same.
Demo data
The tutorial needs at least one product with a purchase price. If you do not want to create one yourself, generate demo data instead. The generator ships with shopware/dev-tools, so install that first:
shopware-cli project composer require --dev shopware/dev-toolsThen generate the data and refresh the search indices:
shopware-cli project console framework:demodata --env=prodshopware-cli project console dal:refresh:indexThis creates 1,000 products with random prices and purchase prices, plus customers, orders and categories. All three commands take about two minutes together. --env=prod is required: the generator refuses to run in the dev environment.
The plugin
Create this structure below your shop's custom/plugins directory:
custom/plugins/SwagProductMargin/
├── composer.json
└── src/
├── SwagProductMargin.php
└── Resources/
└── app/
└── administration/
└── src/
└── main.tsThe path matters: Shopware finds your Administration code at src/Resources/app/administration/src/, and main.ts inside it is the entry point. The rest of this tutorial writes <plugin root> for custom/plugins/SwagProductMargin, so that directory is:
<plugin root>/src/Resources/app/administration/src/Everything below it is yours to organise into whatever directories you like - the build searches the whole tree. This tutorial ends up with override/, component/ and override-demo/ directories, but nothing depends on those names.
main.ts is the one file you create empty. The main flow of this tutorial leaves it empty, because the build finds your code on its own, but it has to exist for the plugin to be picked up:
// <plugin root>/src/Resources/app/administration/src/main.ts
// Intentionally empty: overrides register themselves and components are imported where they are used.// <plugin root>/composer.json
{
"name": "swag/product-margin",
"description": "Warns when a product's profit margin is too low",
"type": "shopware-platform-plugin",
"license": "MIT",
"autoload": {
"psr-4": {
"Swag\\ProductMargin\\": "src/"
}
},
"extra": {
"shopware-plugin-class": "Swag\\ProductMargin\\SwagProductMargin",
"label": {
"en-GB": "Product margin"
}
}
}// <plugin root>/src/SwagProductMargin.php
<?php declare(strict_types=1);
namespace Swag\ProductMargin;
use Shopware\Core\Framework\Plugin;
class SwagProductMargin extends Plugin
{
}More on the PHP side
This tutorial keeps the PHP to the absolute minimum. Plugin metadata, versioning, lifecycle methods and services are covered in the Plugin base guide.
Install and switch it on:
shopware-cli project console plugin:refreshshopware-cli project console plugin:install --activate SwagProductMarginYou need those two once for each new plugin. Editing files inside an already-activated plugin does not need them.
Build the Administration
Your .vue files are compiled into the Administration bundle. Pick the right command and you save a lot of waiting:
Turn on editor support
Everything the build rejects is also reported by ESLint, on the exact line, as you type. Setting that up before you write the first component is worth the one command:
shopware-cli project console administration:setup-extension-toolingIt writes a tsconfig.json and an eslint.config.mjs into your plugin and shows you which settings to configure in your IDE.
You can run the checks by hand with this command:
shopware-cli project console administration:check-extensions -- --only=SwagProductMargin SwagProductMargin custom/plugins/SwagProductMargin
TypeScript ✔ passed managed · 4.9s
ESLint ✔ passed managed · 3.6sThe -- is required: everything after it is passed on to the checker, and without it the console rejects --only as an unknown option.
vue-tsc is not installed
If the check reports that vue-tsc is not installed, run this command:
docker compose exec web npm ci --prefix vendor/shopware/administration/Resources/app/administrationWorking inside shopware/shopware?
In the shopware/shopware repository itself, composer admin:setup-extension-tooling and composer admin:check-extensions do the same.
Experimental
Both commands were newly introduced and their usage may still change. Give us feedback.
Checkpoint
Open the Administration and go to Extensions → My extensions. Search for Product margin: it is listed and switched on.

Nothing else is visible yet, because the plugin has no Administration code. That is Chapter 2.