# ExampleController - "\\ExampleController does not exist"

**URL:** <https://forum.shopware.com/t/examplecontroller-examplecontroller-does-not-exist/90450>\
**Category:** Programmierung\
**Tags:** programming\
**Created:** [21. September 2021 um 08:27 UTC](https://forum.shopware.com/t/examplecontroller-examplecontroller-does-not-exist/90450 "2021-09-21T08:27:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hardy123480](https://avatars.discourse-cdn.com/v4/letter/h/ea5d25/32.png) [@hardy123480](https://forum.shopware.com/u/hardy123480)\
**Post date:** [21. September 2021 um 08:27 UTC](https://forum.shopware.com/t/examplecontroller-examplecontroller-does-not-exist/90450/1 "2021-09-21T08:27:42Z")

</div>

Hallo,

ich habe einen ExampleController erstellt und bin exakt diesen Schritten gefolgt: [Add custom controller - Shopware Developer](https://developer.shopware.com/docs/guides/plugins/plugins/storefront/add-custom-controller#adding-custom-storefront-controller)

Dennoch erhalte ich folgende Fehlermeldung:

` Class Swag\BasicExample\Storefront\Controller\ExampleController does not exist in /custom/plugins/SwagBasicExample/src/Storefront/Controller/ExampleController.php (which is being imported from "/custom/plugins/SwagBasicExample/src/Resources/config/routes.xml"). Make sure to use PHP 8+ or that annotations are installed and enabled.`

Ich verstehe das nicht. Die Klasse ExampleController existiert in ExampleController.php. Ich verwende PHP 7.4, aber daran dürfte es doch nicht scheitern?

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [21. September 2021 um 09:05 UTC](https://forum.shopware.com/t/examplecontroller-examplecontroller-does-not-exist/90450/2 "2021-09-21T09:05:18Z")

</div>

Doch, genau das sagt die Fehlermeldung aus. PHP 8 oder PHP 7 mit Annotations Modul.

---

<div class="post-metadata">

**Author:** ![AlexGalax](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/alexgalax/32/9925_2.png) [@AlexGalax](https://forum.shopware.com/u/AlexGalax)\
**Post date:** [21. September 2021 um 10:55 UTC](https://forum.shopware.com/t/examplecontroller-examplecontroller-does-not-exist/90450/3 "2021-09-21T10:55:11Z")

</div>

> [@hardy123480](#):
>
> aber daran dürfte es doch nicht scheitern?

Genau, dann würde ja der ganze Shop schon vorher nicht funktionieren.

Hast du in den Annotations die Werte vielleicht in Single-Quotes `'` gemacht? Die müssen nämlich in Doppel-Quotes `"`

Falsch:

```php
/**
 * @RouteScope(scopes={'storefront'})
 */

```

Richtig:

```php
/**
 * @RouteScope(scopes={"storefront"})
 */

```

---

<div class="post-metadata">

**Author:** ![hardy123480](https://avatars.discourse-cdn.com/v4/letter/h/ea5d25/32.png) [@hardy123480](https://forum.shopware.com/u/hardy123480)\
**Post date:** [21. September 2021 um 12:58 UTC](https://forum.shopware.com/t/examplecontroller-examplecontroller-does-not-exist/90450/4 "2021-09-21T12:58:41Z")

</div>

Hey, ja, sind Doppel-Quotes.  
Ich verstehe das nicht. Es ist alles exakt so wie im verlinkten Tutorial. Daher verstehe ich nicht, woran es scheitern kann.

---

<div class="post-metadata">

**Author:** ![AlexGalax](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/alexgalax/32/9925_2.png) [@AlexGalax](https://forum.shopware.com/u/AlexGalax)\
**Post date:** [21. September 2021 um 13:47 UTC](https://forum.shopware.com/t/examplecontroller-examplecontroller-does-not-exist/90450/5 "2021-09-21T13:47:24Z")

</div>

Irgendwas stimmt mit den Annotations nicht, mehr kann ich von hier auch nicht sagen. Zeig mal die Controller.php

---

<div class="post-metadata">

**Author:** ![hardy123480](https://avatars.discourse-cdn.com/v4/letter/h/ea5d25/32.png) [@hardy123480](https://forum.shopware.com/u/hardy123480)\
**Post date:** [21. September 2021 um 15:32 UTC](https://forum.shopware.com/t/examplecontroller-examplecontroller-does-not-exist/90450/6 "2021-09-21T15:32:02Z")

</div>

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

namespace Swag\BasicExample\Storefront\Controller;

use Shopware\Core\Framework\Routing\Annotation\RouteScope;
use Shopware\Core\System\SalesChannel\SalesChannelContext;
use Shopware\Storefront\Controller\StorefrontController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
 * @RouteScope(scopes={"storefront"})
 */
class ExampleController extends StorefrontController
{
    /**
     * @Route("/example", name="frontend.example.example", methods={"GET"})
     */
    public function showExample(): Response
    {
        return $this->renderStorefront('@SwagBasicExample/storefront/page/example/index.html.twig', [
            'example' => 'Hello world'
        ]);
    }
}

```

Danke schon mal.

---

<div class="post-metadata">

**Author:** ![AlexGalax](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/alexgalax/32/9925_2.png) [@AlexGalax](https://forum.shopware.com/u/AlexGalax)\
**Post date:** [22. September 2021 um 05:42 UTC](https://forum.shopware.com/t/examplecontroller-examplecontroller-does-not-exist/90450/7 "2021-09-22T05:42:38Z")

</div>

Hm, die sieht gut aus; zeig doch mal die `routes.xml` und `servicxe.xml`
