# Controller und PHP-Namespace

**URL:** https://forum.shopware.com/t/controller-und-php-namespace/59297
**Category:** Programmierung
**Created:** [29. April 2019 um 12:00 UTC](https://forum.shopware.com/t/controller-und-php-namespace/59297 "2019-04-29T12:00:59Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![paddelboot](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@paddelboot](https://forum.shopware.com/u/paddelboot)
#### Post date: [29. April 2019 um 12:00 UTC](https://forum.shopware.com/t/controller-und-php-namespace/59297/1 "2019-04-29T12:00:59Z")

</div>

Hier: [FroshProfiler/Profiler.php at master · FriendsOfShopware/FroshProfiler · GitHub](https://github.com/FriendsOfShopware/FroshProfiler/blob/master/Controller/Frontend/Profiler.php) sehe ich einen Controller, der PHP-Namespaces verwendet, und nicht den eher altmodischen Ansatz mit Klassennamen und Namespace-Präfixen, wie in der Dokumentation vorgeschlagen ([Shopware controller](https://developers.shopware.com/developers-guide/controller/)). Wenn ich versuche, den Controller mit PHP-Namespace zu erweitern, wirft Shopware allerdings eine Fehlermeldung:

„Class Shopware\_Controllers\_Frontend\_Ersatzteilsuche does not exist […]“

Muss ich die Controller mit PHP-Namespace manuell registrieren oder so etwas?

Danke & Grüße, Paddelboot

---

<div class="post-metadata">

### Author: ![WernerBu](https://avatars.discourse-cdn.com/v4/letter/w/71c47a/32.png) [@WernerBu](https://forum.shopware.com/u/WernerBu)
#### Post date: [29. April 2019 um 12:08 UTC](https://forum.shopware.com/t/controller-und-php-namespace/59297/2 "2019-04-29T12:08:33Z")

</div>

Hallo,

&nbsp;

ah, interessant.

Aber dann muß man den wohl registrieren, haben die zumindest gemacht.

> <https://github.com/FriendsOfShopware/FroshProfiler/blob/master/Subscriber/ProfilerController.php>

Viele Grüße,

Werner.

&nbsp;

---

<div class="post-metadata">

### Author: ![shyim](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/shyim/32/7681_2.png) [@shyim](https://forum.shopware.com/u/shyim)
#### Post date: [29. April 2019 um 12:14 UTC](https://forum.shopware.com/t/controller-und-php-namespace/59297/3 "2019-04-29T12:14:43Z")

</div>

Genau diese Controller müssen selbst registriert werden via Subscriber. Alternativ autoregister von Controllern verwenden

FYI: Ab Shopware 5.6 ist das nicht mehr alles nötig, man kann Controller als Services anlegen&nbsp;[https://github.com/shopware/shopware/blob/5.6/UPGRADE-5.6.md#controller-registration-using-di-tag](https://github.com/shopware/shopware/blob/5.6/UPGRADE-5.6.md#controller-registration-using-di-tag)

---

<div class="post-metadata">

### Author: ![paddelboot](https://avatars.discourse-cdn.com/v4/letter/p/e95f7d/32.png) [@paddelboot](https://forum.shopware.com/u/paddelboot)
#### Post date: [29. April 2019 um 12:20 UTC](https://forum.shopware.com/t/controller-und-php-namespace/59297/4 "2019-04-29T12:20:00Z")

</div>

> [@WernerBu schrieb:](https://forum.shopware.com/profile/28422/WernerBu "WernerBu")
> 
> Hallo,
> 
> &nbsp;
> 
> ah, interessant.
> 
> Aber dann muß man den wohl registrieren, haben die zumindest gemacht.
> 
> [https://github.com/FriendsOfShopware/FroshProfiler/blob/master/Subscriber/ProfilerController.php](https://github.com/FriendsOfShopware/FroshProfiler/blob/master/Subscriber/ProfilerController.php)
> 
> Viele Grüße,
> 
> Werner.
> 
> &nbsp;

Danke, hatte ich übersehen. Irgendwie fies, eine Subscriber-Klasse, die dazu dient, einen Controller zu registrieren. Die Mischung aus Klassennamen-Namespace in Controllern und PHP-Namespace (zB. in den Serviceklassen) scheint mir auch nicht ganz das Gelbe vom Ei.

&nbsp;

@Shyim Danke, derzeit läuft bei mir allerdings die 5.5.8.
