Creating a service


6.0.0 or newer

Table of contents


Creating custom services for your plugin is as simple as it is in Symfony bundles, since Shopware 6 plugins are basically just extended Symfony bundles. Make sure to have a look at the Symfony documentation, to find out how services are registered in Symfony itself.

Registering your service

The main requirement here is to have a services.xml file placed into Resources/config/ folder. The services are automatically registered via autoloading.

From here on, everything works exactly like in Symfony itself.

Here's an example services.xml:

<?xml version="1.0" ?>

<container xmlns=""

        <service id="Swag\CustomService\Service\MyService" />

And the related example service:

<?php declare(strict_types=1);

namespace Swag\CustomService\Service;

class MyService
    public function doSomething(): void

Note: By default, all services in Shopware 6 are marked as private. Read more about private and public services here.


There's a GitHub repository available, containing this example source. Check it out here.

Was this article helpful?