# Wie kann ich Shopware Evnet-Subscriber richtig benutzen

**URL:** <https://forum.shopware.com/t/wie-kann-ich-shopware-evnet-subscriber-richtig-benutzen/54952>\
**Category:** Programmierung\
**Created:** [3. September 2018 um 10:35 UTC](https://forum.shopware.com/t/wie-kann-ich-shopware-evnet-subscriber-richtig-benutzen/54952 "2018-09-03T10:35:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nwei](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@nwei](https://forum.shopware.com/u/nwei)\
**Post date:** [3. September 2018 um 10:35 UTC](https://forum.shopware.com/t/wie-kann-ich-shopware-evnet-subscriber-richtig-benutzen/54952/1 "2018-09-03T10:35:23Z")

</div>

Hi, I’ve created a custom plugin&nbsp;_SwagStartup_&nbsp;in Shopware, and it works by calling an url like “shopware.project/myDemo”.

Then I tried to define/use event subscriber in this plugin, following is the code:

&nbsp;

```
namespace SwagStartup\Subscriber;
use Enlight\Event\SubscriberInterface;

class RoutingSubscriber implements SubscriberInterface
{
    public static function getSubscribedEvents(){
        return ['Enlight_Controller_Action_PreDispatch' => 'onPreDispatch'];
    }
    public function onPreDispatch(Enlight_Event_EventArgs $args){
        die('here!');
    }
}

```

And the XML file: Resources/services.xml:

When I called the url like before, I expected to see the output from the die() function, cause I thought the event&nbsp;_Enlight\_Controller\_Action\_PreDispatch_&nbsp;should have been caught by the subscriber and the funciton&nbsp;_onPreDispatch()_&nbsp;should have been called - but it was not the case.

What’s wrong? Can someone tell me?

---

<div class="post-metadata">

**Author:** ![nwei](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@nwei](https://forum.shopware.com/u/nwei)\
**Post date:** [3. September 2018 um 11:21 UTC](https://forum.shopware.com/t/wie-kann-ich-shopware-evnet-subscriber-richtig-benutzen/54952/2 "2018-09-03T11:21:18Z")

</div>

Problem bereits geloest!

---

<div class="post-metadata">

**Author:** ![devo](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@devo](https://forum.shopware.com/u/devo)\
**Post date:** [10. März 2021 um 08:47 UTC](https://forum.shopware.com/t/wie-kann-ich-shopware-evnet-subscriber-richtig-benutzen/54952/3 "2021-03-10T08:47:52Z")

</div>

Und wie sieht die Lösung aus oder war es heilen durch Hand auflegen? 🙂
