【问题标题】:Symfony with easyadmin - homepage getting redirected to admin page带有easyadmin的Symfony - 主页被重定向到管理页面
【发布时间】:2020-07-26 23:00:46
【问题描述】:

我正在按照本教程使用 Symfony 5.0.4 和 easyadmin。 https://symfony.com/doc/master/bundles/EasyAdminBundle/index.html

安装easyadmin后,我尝试获取我的主页https://127.0.0.1:8000/。 但它重定向到/admin。 默认设置所有配置文件。

如何加载主页而不被重定向?

【问题讨论】:

标签: php symfony easyadmin


【解决方案1】:

您应该更新config\packages\easy_admin.yaml 文件并将主页链接添加到菜单中:

easy_admin:
    design:
        menu:
            - { route: 'homepage', label: 'Back to the website', icon: 'home'} 

不要忘记将“主页”替换为您的路线页面的路线名称。 您可以按类型查找到您主页的路径:

symfony console debug:route

PS:如果 debug:route 命令未知,请安装 debug-pack:

symfony composer req debug --dev

然后你必须在你的代码中搜索与主页路由对应的控制器。 这是一个例子:

class DefaultController extends AbstractController
{
    /**
     * @Route("/", name="homepage") <== This is the method called when I wand to display the homepage
     */
    public function index(): Response
    {
        return new Response('This is an example');
    }
}
You should find the method called in your application and verify its code to find why it redirects you to the easyadmin route.

【讨论】:

    【解决方案2】:

    非常感谢你,亚历山大!

    问题出在全局路由上。我不知道为什么。

    例子:

    #

    /** * @Route("/", name="labs_") */

    类 IndexController 扩展 AbstractController {

    #

    当我在所有主页中移动路线时,一切都开始工作了。

    【讨论】:

      猜你喜欢
      • 2017-07-23
      • 1970-01-01
      • 2021-01-28
      • 2013-01-31
      • 2018-03-28
      • 2011-12-25
      • 2018-03-06
      • 2017-07-09
      • 2015-05-30
      相关资源
      最近更新 更多