[SOLVED] Routing does not work for own controller

I would like to output a Google News Sitemap for my project. Unfortunately I always get a 404 message. Additionally there are contradictory statements in the ./flow routing:*

There is nothing in the error logs.

Here my code:

Routings.yaml

- name: 'GoogleNews'
  uriPattern: 'sitemap-news.xml'
  defaults:
    '@package': 'FooBar'
    '@controller': 'GoogleNews'
    '@action': 'sitemap'
    '@format': 'xml'

Settings.yaml

Neos:
    Flow:
        mvc:
            routes:
                F03.DmgDriven:
                    position: 'start'

./flow routing:list

Currently registered routes:
1. sitemap-news.xml Foo.Bar :: GoogleNews
.....
91.  Neos.Flow :: fallback

./flow routing:routepath sitemap-news.xml

Path:
  sitemap-news.xml
Route:
  Name: Neos.Neos :: Frontend :: Homepage
  Pattern: {node}
Result:
  Package: Neos.Neos
  Subpackage: -
  Controller: Frontend\Node
  Action: show
  Format: html
Controller:
  Neos\Neos\Controller\Frontend\NodeController

You seem to have a typo in your route definition (you can tell by the @package part turning red above).

./flow routing:show 1

will probably reveal the issue:

...
  Defaults:
- @package => FooBar'

…also to test your route via CLI you need to prefix a leading slash apparently:

./flow routing:routepath /sitemap-news.xml

Thx. The typo watch only a copy past fail. in my routing.yaml it is correct.

the correct call of ./flow routing:routepath /sitemap-news.xml

gives me a other error now.

Path:
  /sitemap-news.xml
Route:
  Name: Foo.Bar :: GoogleNews
  Pattern: sitemap-news.xml
Result:
  Package: Foo.Bar
  Subpackage: -
  Controller: GoogleNews
  Action: sitemap
  Format: xml
Controller Error:
  !!! No Controller Object found !!!

This is where the Controller is:
DistributionPackages/Foo.Bar/Classes/Controller/GoogleNewsController.php and is has the method: sitemapAction

I missed this in my composer.json m(

"autoload": {
    "psr-4": {
      "Foo\\Bar\\": "Classes"
    }
}

Great.
Whenever you come across a routing exception make sure to take a look into the System log. There’s usually more information about the error to be found.

Can I mark this issue as resolved?

Yes, please and Thx for your help.

1 Like