# Service class not found

**URL:** <https://forum.shopware.com/t/service-class-not-found/92574>\
**Category:** Programmierung\
**Tags:** general, programming\
**Created:** [25. Januar 2022 um 13:09 UTC](https://forum.shopware.com/t/service-class-not-found/92574 "2022-01-25T13:09:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZOth](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@ZOth](https://forum.shopware.com/u/ZOth)\
**Post date:** [25. Januar 2022 um 13:09 UTC](https://forum.shopware.com/t/service-class-not-found/92574/1 "2022-01-25T13:09:45Z")

</div>

Hallo guten Tag,  
Ich bin neu bei shopware 6 und habe schon das docu über plugins gelesen,  
Ich habe folgende problem.  
Ich habe unter src/Resources/config/services.xml

```auto
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <services>
        <service id="Twp\ArContent\Subscriber\ArContentSubscriber">
            <argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService" />
            <tag name="kernel.event_subscriber"/>
        </service>
    </services>
</container>

```

und have unter src/Resources/Subscriber/ArContentSubscriber.php

```auto
<?php declare(strict_types=1);

namespace Twp\ArContent\Subscriber;

use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Core\Content\Product\ProductEvents;
use Shopware\Core\System\SystemConfig\SystemConfigService;

class ArContentSubscriber implements EventSubscriberInterface
{
    private SystemConfigService $systemConfigService;

    public function __construct(SystemConfigService $systemConfigService)
    {
        $this->systemConfigService = $systemConfigService;
    }

    public static function getSubscribedEvents(): array
    {
        return [
            ProductEvents::PRODUCT_LOADED_EVENT => 'onProductsLoaded'
        ];
    }

    public function onProductsLoaded(EntityLoadedEvent $event): void
    {
        $exampleConfig = $this->systemConfigService->get('TwpArContent.config.ArContentConfig');
        echo "hallo";
        // Do stuff with the product
    }
}

```

jetzt wenn ich im SSH cache:clear eingebe bekomme ich folgende error

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/a/a8b5f67ca80c31b482b9b1f691868fcf4ec36188.png)  
Was ist das problem ? die service id bezieht sich doch über die namespace von meine ArContentSubscriber.php und die klasse oder?  
Danke

---

<div class="post-metadata">

**Author:** ![ZOth](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@ZOth](https://forum.shopware.com/u/ZOth)\
**Post date:** [25. Januar 2022 um 14:04 UTC](https://forum.shopware.com/t/service-class-not-found/92574/2 "2022-01-25T14:04:35Z")

</div>

subscriber namespace pfad war falsch, gelöst danke

---

<div class="post-metadata">

**Author:** ![SPO](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@SPO](https://forum.shopware.com/u/SPO)\
**Post date:** [21. April 2022 um 14:32 UTC](https://forum.shopware.com/t/service-class-not-found/92574/3 "2022-04-21T14:32:48Z")

</div>

Hi ZOth,

verzweifle gerade an gleicher Stelle und habe wohl Tomaten auf den Augen…

Wie ist denn der namespace richtig in deinen Beispiel?

---

<div class="post-metadata">

**Author:** ![ZOth](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@ZOth](https://forum.shopware.com/u/ZOth)\
**Post date:** [22. April 2022 um 10:33 UTC](https://forum.shopware.com/t/service-class-not-found/92574/4 "2022-04-22T10:33:07Z")

</div>

Hi SPO, @SPO  
i dont quite remember that plugin as i changed it and made a new one, but i guess i was missing Storefront folder, however i can give u some tips if u have the same problem.

1. make sure your subscriber is placed under MyPluginname/src/Storefront/Subscriber/YourSubscriber.php
2. your subscriber.php namespace should have the exact path to your subscriber file, in my case

```auto
namespace My\Pluginname\Storefront\Subscriber;

class YourSubscriber implements EventSubscriberInterface

```

3.Then make sure to have your subscriber included in your services, in this case

```auto
<services>
        <service id="My\Pluginname\Storefront\Subscriber\YourSubscriber">
            <tag name="kernel.event_subscriber"/>
        </service>
    </services>

```

it is also very important that your composer.js auto load is starting from path src

```auto
    "autoload": {
        "psr-4": {
            "My\\Pluginname\\": "src/"
        }
    }

```

if you still dont know how to fix it please show me your code :=)
