FrameworkBundle:Redirect:redirect 的 Symfony 5 语法?

Symfony 5 Syntax for FrameworkBundle:Redirect:redirect?

我将我的环境从 symfony 4.4 升级到 5.4,之后我得到以下错误:

The controller for URI "/" is not callable: Controller "FrameworkBundle:Redirect:redirect" does neither exist as service nor as class.

如果我使用 /admin/dashboard 等其他网址,它会很好用。

我的 routes.yaml 中有这个条目,它似乎是来源:

dwbn_login_target:
  path: /
  defaults:
    _controller: FrameworkBundle:Redirect:redirect
    route: sonata_admin_dashboard
    permanent: false # this for 301path: /

如何在 symfony 5 中实现 FrameworkBundle:Redirect:redirect

此处记录了 Symfony 5 中的首选方式:

https://symfony.com/doc/5.4/routing.html#redirecting-to-urls-and-routes-directly-from-a-route

你的情况:

dwbn_login_target:
    path: /
    controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController
    defaults:
        route: 'sonata_admin_dashboard'
        permanent: false