Service class not found

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

<?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

<?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


Was ist das problem ? die service id bezieht sich doch über die namespace von meine ArContentSubscriber.php und die klasse oder?
Danke

subscriber namespace pfad war falsch, gelöst danke

Hi ZOth,

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

Wie ist denn der namespace richtig in deinen Beispiel?

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
namespace My\Pluginname\Storefront\Subscriber;

class YourSubscriber implements EventSubscriberInterface

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

<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

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

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